Skip to content

Instantly share code, notes, and snippets.

@vs0uz4
Last active May 18, 2020 15:02
Show Gist options
  • Save vs0uz4/11c039e342a0a211d06e0b3dd13c6a0b to your computer and use it in GitHub Desktop.
Save vs0uz4/11c039e342a0a211d06e0b3dd13c6a0b to your computer and use it in GitHub Desktop.
renders movie list with 2 movies even when the list contains more movies but only 2 of them contain backdrop_path
import '@testing-library/jest-dom/extend-expect';
import { render, fireEvent, getAllByTestId } from '@testing-library/svelte';
import MovieList from '../components/movies/MovieList';
import { store, INITIAL_STATE } from '../store';
import moviesMock from './mocks/movies.json';
describe("Movie List", () => {
it("renders movie list with 2 movies even when the list contains more movies but only 2 of them contain backdrop_path", () => {
setStore({ movies: moviesMock.results });
const { getByTestId, getAllByTestId } = render(MovieList);
const movieItems = getAllByTestId('movie-item');
const movies = moviesMock.results;
expect(getByTestId('movie-list')).toBeInTheDocument();
expect(movieItems).toHaveLength(2);
expect(movieItems.length).toBeLessThan(movies.length);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment