-
-
Save AlexLakatos/535cf15d06806b5c5ffc72bea37ad5fb to your computer and use it in GitHub Desktop.
greeter.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Component: Greeter', () => { | |
let fixture, greeter, element, de; | |
//setup | |
beforeEach(() => { | |
TestBed.configureTestingModule({ | |
declarations: [ Greeter ] | |
}); | |
fixture = TestBed.createComponent(Greeter); | |
greeter = fixture.componentInstance; // to access properties and methods | |
element = fixture.nativeElement; // to access DOM element | |
de = fixture.debugElement; // test helper | |
}); | |
//specs | |
it('should render `Hello World!`', async(() => { | |
greeter.name = 'World'; | |
//trigger change detection | |
fixture.detectChanges(); | |
fixture.whenStable().then(() => { | |
expect(element.querySelector('h1').innerText).toBe('Hello World!'); | |
expect(de.query(By.css('h1')).nativeElement.innerText).toBe('Hello World!'); | |
}); | |
})); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment