-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathEpisode.test.js
46 lines (40 loc) · 1.67 KB
/
Episode.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from "react";
import { render, screen } from "@testing-library/react";
import Episode from "./../Episode";
const testEpisode = {
id: 1,
name: "",
image:
"http://static.tvmaze.com/uploads/images/medium_landscape/67/168918.jpg",
season: 1,
number: 1,
summary: "test summary",
runtime: 1
};
const testEpisodeWithoutImage = {
id: 1,
name: "",
image:"null",
season: 1,
number: 1,
summary: "test summary",
runtime: 1
};
test("renders without error", () => {
render(<Episode episode={testEpisode} />);
});
test("renders the summury test passed as prop", () => {
render(<Episode episode={testEpisode} />);
const summary = screen.queryByText(/test summary/i);
expect(summary).toBeInTheDocument();
expect(summary).toBeTruthy();
expect(sumary).toHaveTextContent("test summary");
test("renders default image when image is not defined", () => {
render(<Episode episode={testEpisodeWithoutImage} />);
const image = screen.queryByAltText('./stranger_things.png')
expect(image).toBeInTheDocument();
});
//Tasks
//1. Complete a test that shows the Episode component renders. Pass in the provided example episode data as a test prop.
//2. Modify the test data to display a specific summary statement. Complete a test that shows that the summary value passed in to the Episode component displays as expected. Use no more then 3 different expect statements to test the the existance of the summary value.
//3. The episode component displays a default value ('./stranger_things.png') when a image url is not provided. Create a new piece of test data with the image property set to null. Test that the alt tag of the image displayed is set to './stranger_things.png'.