Skip to content

Instantly share code, notes, and snippets.

@FunnyGhost
Last active March 12, 2019 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FunnyGhost/6f49e199262123f41eef7d499e8f85a9 to your computer and use it in GitHub Desktop.
Save FunnyGhost/6f49e199262123f41eef7d499e8f85a9 to your computer and use it in GitHub Desktop.
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