File tree Expand file tree Collapse file tree 3 files changed +63
-2
lines changed Expand file tree Collapse file tree 3 files changed +63
-2
lines changed Original file line number Diff line number Diff line change 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+
2327export default GifExpertApp ;
2428
Original file line number Diff line number Diff line change 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+
Original file line number Diff line number Diff line change 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+ ` ;
You can’t perform that action at this time.
0 commit comments