Skip to content

Commit 9534ba9

Browse files
committed
[ADD]🚀 GifExpertApp tests added
1 parent 44f32a6 commit 9534ba9

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

‎src/GifExpertApp.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
ListCategories
66
} from './components';
77

8-
const GifExpertApp = () => {
9-
const [categories, setCategories] = useState(['Dragon Ball']);
8+
const GifExpertApp = ({ defaultCategories }) => {
9+
const [categories, setCategories] = useState(defaultCategories);
1010

1111
return (
1212
<>
@@ -20,5 +20,9 @@ const GifExpertApp = () => {
2020
);
2121
}
2222

23+
GifExpertApp.defaultProps = {
24+
defaultCategories: []
25+
}
26+
2327
export default GifExpertApp;
2428

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { shallow } from 'enzyme';
3+
4+
import GifExpertApp from '../GifExpertApp';
5+
6+
describe('Tests GifExpertApp component', () => {
7+
test('Should display correctly', () => {
8+
const wrapper = shallow(<GifExpertApp />);
9+
expect(wrapper).toMatchSnapshot();
10+
});
11+
12+
test('Should show a list of categories', () => {
13+
const categories = ['Dragon Ball', 'Samurai X'];
14+
const wrapper = shallow(<GifExpertApp defaultCategories={categories} />);
15+
const currentCategories = wrapper.find('ListCategories').prop('categories');
16+
17+
expect(wrapper).toMatchSnapshot();
18+
expect(currentCategories.length).toBe(categories.length);
19+
});
20+
});
21+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Tests GifExpertApp component Should display correctly 1`] = `
4+
<Fragment>
5+
<h2>
6+
GifExpertApp
7+
</h2>
8+
<AddCategory
9+
setCategories={[Function]}
10+
/>
11+
<hr />
12+
<ListCategories
13+
categories={Array []}
14+
/>
15+
</Fragment>
16+
`;
17+
18+
exports[`Tests GifExpertApp component Should show a list of categories 1`] = `
19+
<Fragment>
20+
<h2>
21+
GifExpertApp
22+
</h2>
23+
<AddCategory
24+
setCategories={[Function]}
25+
/>
26+
<hr />
27+
<ListCategories
28+
categories={
29+
Array [
30+
"Dragon Ball",
31+
"Samurai X",
32+
]
33+
}
34+
/>
35+
</Fragment>
36+
`;

0 commit comments

Comments
 (0)