Created
December 5, 2019 12:48
-
-
Save FunnyGhost/3e1c9f279719eac23ab047a1be83d6a6 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
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