File tree 4 files changed +45
-5
lines changed
4 files changed +45
-5
lines changed Original file line number Diff line number Diff line change 21
21
},
22
22
"devDependencies" : {
23
23
"enzyme" : " ^3.10.0" ,
24
- "enzyme-adapter-react-16" : " ^1.14.0"
24
+ "enzyme-adapter-react-16" : " ^1.14.0" ,
25
+ "redux-mock-store" : " ^1.5.3"
25
26
}
26
27
}
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import MatchesUserItem from './MatchesUserItem';
4
4
import { getMatchedUsers } from '../reduxStore/actions/userAction' ;
5
5
import { Redirect } from 'react-router-dom' ;
6
6
7
- class MatchesUserList extends Component {
7
+ export class MatchesUserList extends Component {
8
8
constructor ( props ) {
9
9
super ( props ) ;
10
10
this . state = {
Original file line number Diff line number Diff line change @@ -5,9 +5,21 @@ import {matchsUsers} from './testing_data';
5
5
6
6
describe ( "MatchesUserItem tests" , ( ) => {
7
7
it ( "render users" , ( ) => {
8
- const users = matchsUsers . users ;
9
- const wrapper = shallow ( < MatchesUserItem user = { users [ 0 ] } /> ) ;
8
+ const user = matchsUsers . users [ 0 ] ;
9
+ const wrapper = shallow ( < MatchesUserItem user = { user } /> ) ;
10
10
expect ( wrapper . find ( ".maches-user-item" ) ) . toBeDefined ( ) ;
11
11
expect ( wrapper . find ( ".img-user-profile" ) ) . toBeDefined ( ) ;
12
- } )
12
+ } ) ;
13
+ it ( "render user details" , ( ) => {
14
+ const user = matchsUsers . users [ 0 ] ;
15
+ const wrapper = shallow ( < MatchesUserItem user = { user } /> ) ;
16
+ expect ( wrapper . contains ( < div className = "d-flex" >
17
+ < img className = "img-user-profile" src = { user . profile } alt = "User Image" width = "60px" height = "60px" />
18
+ < div style = { { marginLeft : '10px' } } >
19
+ < label > y</ label > < br />
20
+ < label > { user . location } </ label >
21
+ </ div >
22
+ </ div > ) ) ;
23
+ } ) ;
24
+
13
25
} )
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { shallow } from '../../enzyme' ;
3
+ import { matchsUsers } from './testing_data' ;
4
+ import ConnectedMatchesUserList , { MatchesUserList } from '../MatchesUserList' ;
5
+ import MatchesUserItem from '../MatchesUserItem' ;
6
+ import { Provider } from "react-redux" ;
7
+ import configureMockStore from "redux-mock-store" ;
8
+ const mockStore = configureMockStore ( ) ;
9
+
10
+
11
+ describe ( "MatchesUserList tests" , ( ) => {
12
+ const initialState = { userData : matchsUsers }
13
+ let store , wrapper ;
14
+ beforeEach ( ( ) => {
15
+ store = mockStore ( initialState )
16
+ wrapper = shallow ( < Provider store = { store } >
17
+ < ConnectedMatchesUserList />
18
+ </ Provider > )
19
+ } )
20
+ it ( '+++ render the connected(SMART) component' , ( ) => {
21
+ expect ( wrapper . find ( ConnectedMatchesUserList ) . length ) . toEqual ( 1 )
22
+ } ) ;
23
+
24
+ it ( '+++ check Prop matches with initialState' , ( ) => {
25
+ expect ( wrapper . find ( MatchesUserList ) . prop ( 'userData' ) ) . toEqual ( initialState . userData )
26
+ } ) ;
27
+ } )
You can’t perform that action at this time.
0 commit comments