本文整理汇总了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);
});