本文整理匯總了TypeScript中@angular/core.DebugElement類的典型用法代碼示例。如果您正苦於以下問題:TypeScript DebugElement類的具體用法?TypeScript DebugElement怎麽用?TypeScript DebugElement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了DebugElement類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe('PodcastsComponent', () => {
let comp: PodcastsComponent;
let fixture: ComponentFixture<PodcastsComponent>;
let el: DebugElement;
let store: Store<AppState>;
beforeEach(
async(() => {
TestBed.configureTestingModule({
imports: [
MatToolbarModule,
MatIconModule,
RouterTestingModule,
ToolbarModule,
/* NgRx */
StoreModule.forRoot({}),
StoreModule.forFeature('podcasts', fromPodcasts.reducer)
],
declarations: [PodcastsComponent]
}).compileComponents();
})
);
beforeEach(() => {
store = TestBed.get(Store);
spyOn(store, 'dispatch').and.callThrough();
spyOn(store, 'select').and.callThrough();
});
beforeEach(() => {
store.dispatch(new FindAllSuccess(podcasts));
fixture = TestBed.createComponent(PodcastsComponent);
comp = fixture.componentInstance;
el = fixture.debugElement;
fixture.detectChanges();
});
it('should be created', () => {
expect(comp).toBeTruthy();
});
it('should init with podcasts from resolver', () => {
/* Given */
/* When */
fixture.whenStable().then(() => {
/* Then */
const podcastsCards = el.queryAll(By.css('img'));
expect(podcastsCards.length).toEqual(8);
});
});
it('should open sidenav if click on burger button', () => {
/* Given */
const button = el.query(By.css('.toolbar__hamburger'));
/* When */
button.triggerEventHandler('click', null);
/* Then */
expect(store.dispatch).toHaveBeenCalledWith(new OpenSideNavAction());
});
});
示例2: describe
describe('DotAddContentletComponent', () => {
let component: DotAddContentletComponent;
let de: DebugElement;
let fixture: ComponentFixture<DotAddContentletComponent>;
let dotAddContentletWrapper: DebugElement;
let dotAddContentletWrapperComponent: DotContentletWrapperComponent;
let dotContentletEditorService: DotContentletEditorService;
beforeEach(async(() => {
DOTTestBed.configureTestingModule({
declarations: [DotAddContentletComponent, DotContentletWrapperComponent],
providers: [
DotContentletEditorService,
DotMenuService,
{
provide: LoginService,
useClass: LoginServiceMock
}
],
imports: [DotIframeDialogModule, BrowserAnimationsModule, RouterTestingModule]
}).compileComponents();
}));
beforeEach(() => {
fixture = DOTTestBed.createComponent(DotAddContentletComponent);
de = fixture.debugElement;
component = de.componentInstance;
dotContentletEditorService = de.injector.get(DotContentletEditorService);
spyOn(component.close, 'emit');
fixture.detectChanges();
dotAddContentletWrapper = de.query(By.css('dot-contentlet-wrapper'));
dotAddContentletWrapperComponent = dotAddContentletWrapper.componentInstance;
});
describe('default', () => {
it('should have dot-contentlet-wrapper', () => {
expect(dotAddContentletWrapper).toBeTruthy();
});
it('should emit close', () => {
dotAddContentletWrapper.triggerEventHandler('close', {});
expect(component.close.emit).toHaveBeenCalledTimes(1);
});
it('should have url in null', () => {
expect(dotAddContentletWrapperComponent.url).toEqual(null);
});
it('should set url', () => {
dotContentletEditorService.add({
header: 'Add some content',
data: {
container: '123',
baseTypes: 'content,form'
},
events: {
load: jasmine.createSpy('load'),
keyDown: jasmine.createSpy('keyDown')
}
});
fixture.detectChanges();
expect(dotAddContentletWrapperComponent.url).toEqual(
'/html/ng-contentlet-selector.jsp?ng=true&container_id=123&add=content,form'
);
expect(dotAddContentletWrapperComponent.header).toEqual('Add some content');
});
});
});
示例3: it
it('should be custom actions', () => {
expect(dl.queryAll(By.css('#action-edit')).length).toBe(1);
});
示例4: beforeEach
beforeEach(() => {
fixture.detectChanges();
button = de.query(By.css('dot-icon-button'));
});
示例5: it
it('should not show button', () => {
button = de.query(By.css('dot-icon-button'));
expect(button).toBeNull();
});
示例6: it
it('should display value of 0 by default', () => {
fixture.detectChanges();
const headerElement = el.query(By.css('h1'));
expect(headerElement.nativeElement.textContent).toEqual('hello world zero (ZERO)');
});
示例7: getEmbeddedPlunkerComponent
function getEmbeddedPlunkerComponent() {
const compDe = liveExampleDe.query(By.directive(EmbeddedPlunkerComponent));
return compDe && compDe.componentInstance as EmbeddedPlunkerComponent;
}
示例8: getImg
function getImg() {
const img = liveExampleDe.query(By.css('img'));
return img && img.nativeElement as HTMLImageElement;
}
示例9: it
it('should create an empty variable', () => {
fixture.detectChanges();
de.query(By.css('.action-header__primary-button')).triggerEventHandler('click', { stopPropagation: () => {} });
expect(comp.fieldVariables.length).toBe(4);
expect(comp.fieldVariablesBackup.length).toBe(4);
});