Skip to content

Instantly share code, notes, and snippets.

@FunnyGhost
Last active March 12, 2019 15:30
Show Gist options
  • Save FunnyGhost/fb42c3925d1fcd9f3c7bb54b17f9b6e3 to your computer and use it in GitHub Desktop.
Save FunnyGhost/fb42c3925d1fcd9f3c7bb54b17f9b6e3 to your computer and use it in GitHub Desktop.
const favoriteMoviesToUse: Movie[] = [
{ title: 'Interstellar' } as Movie,
{ title: 'The big Lebowski' } as Movie,
{ title: 'Fences' } as Movie
];
describe('FavoriteMoviesComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(FavoriteMoviesComponent);
component = fixture.componentInstance;
component.favoriteMovies = favoriteMoviesToUse;
});
describe('Render', () => {
it('show all the favorite movies', () => {
const movieElements = fixture.debugElement.queryAll(By.css('.movie'));
expect(movieElements.length).toBe(favoriteMoviesToUse.length);
});
it('should show the movie titles', () => {
const movieElements = fixture.debugElement.queryAll(By.css('.movie'));
movieElements.forEach((movieElement: DebugElement, index) => {
expect(movieElement.nativeElement.innerHTML).toContain(favoriteMoviesToUse[index].title);
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment