| import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; |
|
|
| import { HeroComponent } from './hero.component'; |
|
|
| describe('HeroComponent', () => { |
| let component: HeroComponent; |
| let fixture: ComponentFixture<HeroComponent>; |
|
|
| beforeEach(waitForAsync(() => { |
| TestBed.configureTestingModule({ |
| declarations: [HeroComponent], |
| }).compileComponents(); |
| })); |
|
|
| beforeEach(() => { |
| fixture = TestBed.createComponent(HeroComponent); |
| component = fixture.componentInstance; |
| fixture.detectChanges(); |
| }); |
|
|
| it('should create', () => { |
| expect(component).toBeTruthy(); |
| }); |
|
|
| it('should render title in a h1 tag', () => { |
| fixture.detectChanges(); |
| const compiled = fixture.debugElement.nativeElement; |
| expect(compiled.querySelector('h1').textContent).toContain( |
| 'Angular Sample Project' |
| ); |
| }); |
| }); |
|
|