Skip to content

Commit 2a0dcde

Browse files
committed
lint
1 parent 720eeaa commit 2a0dcde

File tree

7 files changed

+76
-73
lines changed

7 files changed

+76
-73
lines changed

Diff for: src/components/Display.js

+26-27
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,31 @@ import Show from "./Show";
66
import fetchShow from '../api/fetchShow';
77

88
const Display = (props) => {
9-
const [show, setShow] = useState(null);
10-
const [selectedSeason, setSelectedSeason] = useState("none");
11-
12-
const { displayFunc } = props;
13-
const handleClick = () => {
14-
fetchShow().then(data => {
15-
setShow(data);
16-
17-
if (displayFunc) {
18-
displayFunc();
19-
}
20-
21-
});
22-
}
23-
24-
const handleSelect = e => {
25-
setSelectedSeason(e.target.value);
26-
};
27-
28-
return (
29-
<div>
30-
<img className="poster-img" src='http://static.tvmaze.com/uploads/images/original_untouched/200/501942.jpg' alt="header image" />
31-
<br/>
32-
{ !show ? <button onClick={handleClick}>Press to Get Show Data</button> :<Show show={show} selectedSeason={selectedSeason} handleSelect={handleSelect}/> }
33-
</div>
34-
);
9+
const [show, setShow] = useState(null);
10+
const [selectedSeason, setSelectedSeason] = useState("none");
11+
const { displayFunc } = props;
12+
13+
const handleClick = () => {
14+
fetchShow().then(data => {
15+
setShow(data);
16+
17+
if (displayFunc) {
18+
displayFunc();
19+
}
20+
});
21+
}
22+
23+
const handleSelect = e => {
24+
setSelectedSeason(e.target.value);
25+
};
26+
27+
return (
28+
<div>
29+
<img className="poster-img" src='http://static.tvmaze.com/uploads/images/original_untouched/200/501942.jpg' alt="header image" />
30+
<br />
31+
{!show ? <button onClick={handleClick}>Press to Get Show Data</button> : <Show show={show} selectedSeason={selectedSeason} handleSelect={handleSelect} />}
32+
</div>
33+
);
3534
}
3635

37-
export default Display;
36+
export default Display;

Diff for: src/components/Episode.js

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
import React from 'react';
22

3-
const Episode = (props)=> {
4-
const {episode} = props;
5-
const {id, image, name, season, number, summary, runtime} = episode;
6-
const imgsrc = image || 'https://i.ibb.co/2FsfXqM/stranger-things.png';
3+
const Episode = (props) => {
4+
const { episode } = props;
5+
const { id, image, name, season, number, summary, runtime } = episode;
6+
const imgsrc = image || 'https://i.ibb.co/2FsfXqM/stranger-things.png';
77

8-
console.log("episode: ", episode);
8+
console.log("episode: ", episode);
99

10-
return(<div className="episode" key={id}>
11-
<img className="episode-image" src={imgsrc} alt={imgsrc} />
12-
<div className="episode-info">
13-
<p className="episode-number">Season {season}, Episode {number}</p>
14-
<h3>{name}</h3>
15-
<p>{summary}</p>
16-
<div className="flex-spacer" />
17-
<p className="episode-runtime">{runtime} minutes</p>
18-
</div>
19-
</div>)
10+
return (
11+
<div className="episode" key={id}>
12+
<img className="episode-image" src={imgsrc} alt={imgsrc} />
13+
<div className="episode-info">
14+
<p className="episode-number">Season {season}, Episode {number}</p>
15+
<h3>{name}</h3>
16+
<p>{summary}</p>
17+
<div className="flex-spacer" />
18+
<p className="episode-runtime">{runtime} minutes</p>
19+
</div>
20+
</div>
21+
)
2022
}
2123

22-
export default Episode;
24+
export default Episode;

Diff for: src/components/Episodes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Episode from './Episode';
44
export default function Episodes(props) {
55
return (
66
<div data-testid="episodes-container" className="episodes">
7-
{props.episodes.map(episode => <Episode episode={episode}/>)}
7+
{props.episodes.map(episode => <Episode episode={episode} />)}
88
</div>
99
);
1010
}

Diff for: src/components/Loading.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

33
const Loading = () => {
4-
return(<h2 data-testid="loading-container">Fetching data...</h2>);
4+
return (<h2 data-testid="loading-container">Fetching data...</h2>);
55
}
66

7-
export default Loading;
7+
export default Loading;

Diff for: src/components/Show.js

+21-19
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,31 @@ import Episodes from "./Episodes";
33
import Loading from './Loading';
44

55
const Show = (props) => {
6-
const { handleSelect, selectedSeason, show } = props;
7-
8-
if (!show)
9-
return <Loading />
6+
const { handleSelect, selectedSeason, show } = props;
107

11-
return(<div data-testid="show-container">
12-
<h1>{show.name}</h1>
13-
<p>{show.summary}</p>
8+
if (!show)
9+
return <Loading />
1410

15-
<label htmlFor="seasons">Select A Season</label><br/>
16-
<select onChange={handleSelect} name="seasons" id="seasons">
17-
<option value="none"></option>
18-
{
19-
show.seasons.map(season=>{
20-
return(<option data-testid="season-option" key={season.id} value={season.id}>{season.name}</option>);
21-
})
22-
}
23-
</select>
11+
return (
12+
<div data-testid="show-container">
13+
<h1>{show.name}</h1>
14+
<p>{show.summary}</p>
2415

16+
<label htmlFor="seasons">Select A Season</label><br />
17+
<select onChange={handleSelect} name="seasons" id="seasons">
18+
<option value="none"></option>
2519
{
26-
(selectedSeason !== "none") && <Episodes episodes={show.seasons[selectedSeason].episodes} />
20+
show.seasons.map(season => {
21+
return (<option data-testid="season-option" key={season.id} value={season.id}>{season.name}</option>);
22+
})
2723
}
28-
</div>);
24+
</select>
25+
26+
{
27+
(selectedSeason !== "none") && <Episodes episodes={show.seasons[selectedSeason].episodes} />
28+
}
29+
</div>
30+
);
2931
}
3032

31-
export default Show;
33+
export default Show;

Diff for: src/components/tests/Episode.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import '@testing-library/jest-dom/extend-expect';
44
import Episode from './../Episode';
55

66

7-
test("renders without error", () => {});
7+
test("renders without error", () => { });
88

9-
test("renders the summary test passed as prop", ()=>{});
9+
test("renders the summary test passed as prop", () => { });
1010

11-
test("renders default image when image is not defined", ()=>{});
11+
test("renders default image when image is not defined", () => { });

Diff for: src/components/tests/Show.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { render, fireEvent, screen } from '@testing-library/react';
33
import '@testing-library/jest-dom/extend-expect';
44
import Show from './../Show';
55

6-
test('renders without errors', ()=>{});
6+
test('renders without errors', () => { });
77

8-
test('renders Loading component when prop show is null', () => {});
8+
test('renders Loading component when prop show is null', () => { });
99

10-
test('renders same number of options seasons are passed in', ()=>{});
10+
test('renders same number of options seasons are passed in', () => { });
1111

12-
test('handleSelect is called when an season is selected', () => {});
12+
test('handleSelect is called when an season is selected', () => { });
1313

14-
test('component renders when no seasons are selected and when rerenders with a season passed in', () => {});
14+
test('component renders when no seasons are selected and when rerenders with a season passed in', () => { });

0 commit comments

Comments
 (0)