Skip to content

Instantly share code, notes, and snippets.

@FunnyGhost
Created December 5, 2019 12:48
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/3e1c9f279719eac23ab047a1be83d6a6 to your computer and use it in GitHub Desktop.
Save FunnyGhost/3e1c9f279719eac23ab047a1be83d6a6 to your computer and use it in GitHub Desktop.
describe('SearchComponent', () => {
beforeEach(() => {
fixture.detectChanges();
});
it('should show the search component', () => {
const searchComponents = fixture.debugElement.queryAll(By.directive(SearchMovieComponent));
expect(searchComponents.length).toEqual(1);
});
it('should add a movie when the user wants to', () => {
jest.spyOn(favoriteMovieService, 'addMovie');
const movieToAdd: Movie = { title: 'Joker' } as Movie;
const searchComponent = fixture.debugElement.query(By.directive(SearchMovieComponent))
.componentInstance as SearchMovieComponent;
searchComponent.addMovie.emit(movieToAdd);
expect(favoriteMovieService.addMovie).toHaveBeenCalledWith(movieToAdd);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment