Skip to content

Commit 6a519a9

Browse files
committed
Angular Testing Course
1 parent d09088a commit 6a519a9

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/app/app.component.spec.ts

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
import { TestBed, async } from '@angular/core/testing';
22
import { RouterTestingModule } from '@angular/router/testing';
33
import { AppComponent } from './app.component';
4+
import {MatIconModule, MatListModule, MatSidenavModule, MatToolbarModule} from '@angular/material';
5+
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
6+
47
describe('AppComponent', () => {
58
beforeEach(async(() => {
69
TestBed.configureTestingModule({
710
imports: [
8-
RouterTestingModule
11+
RouterTestingModule,
12+
MatIconModule,
13+
MatSidenavModule,
14+
MatToolbarModule,
15+
MatListModule,
16+
NoopAnimationsModule
917
],
1018
declarations: [
1119
AppComponent
1220
],
1321
}).compileComponents();
1422
}));
23+
1524
it('should create the app', async(() => {
1625
const fixture = TestBed.createComponent(AppComponent);
1726
const app = fixture.debugElement.componentInstance;
1827
expect(app).toBeTruthy();
1928
}));
29+
2030
it(`should have as title 'app'`, async(() => {
2131
const fixture = TestBed.createComponent(AppComponent);
2232
const app = fixture.debugElement.componentInstance;
23-
expect(app.title).toEqual('app');
24-
}));
25-
it('should render title in a h1 tag', async(() => {
26-
const fixture = TestBed.createComponent(AppComponent);
27-
fixture.detectChanges();
28-
const compiled = fixture.debugElement.nativeElement;
29-
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
33+
expect(app.title).toEqual('Angular Testing Course');
3034
}));
35+
36+
3137
});

src/app/app.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import { Component } from '@angular/core';
66
styleUrls: ['./app.component.css']
77
})
88
export class AppComponent {
9-
title = 'app';
9+
title = 'Angular Testing Course';
1010
}

src/app/app.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import {MatMomentDateModule} from "@angular/material-moment-adapter";
4242
BrowserAnimationsModule,
4343
HttpClientModule,
4444
MatMenuModule,
45-
MatButtonModule,
45+
MatButtonModule,MatToolbarModule,
4646
MatIconModule,
4747
MatCardModule,
4848
MatTabsModule,

0 commit comments

Comments
 (0)