Last active
July 21, 2017 11:07
-
-
Save gsans/96a04ac8ccc64a5b9f1bdaa96ee2e848 to your computer and use it in GitHub Desktop.
greeter.spec.ts
This file contains 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