mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-19 04:26:01 +08:00
fix(@schematics/angular): remove unneeded debugElement in test
The generate tests in `app.component.spec.ts` are using `fixture.debugElement.componentInstance` whereas we can directly use `fixture.componentInstance`. This fixes the generated test to show a better example to users discovering unit tests.
This commit is contained in:
parent
3c9305b37c
commit
3ec4f61357
@ -16,20 +16,20 @@ describe('AppComponent', () => {
|
|||||||
|
|
||||||
it('should create the app', () => {
|
it('should create the app', () => {
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
const app = fixture.debugElement.componentInstance;
|
const app = fixture.componentInstance;
|
||||||
expect(app).toBeTruthy();
|
expect(app).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should have as title '<%= name %>'`, () => {
|
it(`should have as title '<%= name %>'`, () => {
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
const app = fixture.debugElement.componentInstance;
|
const app = fixture.componentInstance;
|
||||||
expect(app.title).toEqual('<%= name %>');
|
expect(app.title).toEqual('<%= name %>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render title', () => {
|
it('should render title', () => {
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const compiled = fixture.debugElement.nativeElement;
|
const compiled = fixture.nativeElement;
|
||||||
expect(compiled.querySelector('.content span').textContent).toContain('<%= name %> app is running!');
|
expect(compiled.querySelector('.content span').textContent).toContain('<%= name %> app is running!');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user