Last active
March 12, 2019 15:14
-
-
Save FunnyGhost/6f49e199262123f41eef7d499e8f85a9 to your computer and use it in GitHub Desktop.
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
it('should show an error if getting the movies fail', () => { | |
const errorToThrow = 'User not found'; | |
jest | |
.spyOn(favoriteMovieService, 'getFavoriteMovies') | |
.mockReturnValue(throwError(errorToThrow)); | |
fixture.detectChanges(); | |
const errorElement = fixture.debugElement.queryAll(By.css('.error')); | |
expect(errorElement.length).toBe(1); | |
expect(errorElement[0].nativeElement.innerHTML).toContain(errorToThrow); | |
}); | |
it('should not show an error if getting the movies succeeds', () => { | |
fixture.detectChanges(); | |
const errorElement = fixture.debugElement.queryAll(By.css('.error')); | |
expect(errorElement.length).toBe(0); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment