11import React from 'react' ; // eslint-disable-line no-unused-vars
2- import { Map } from 'immutable' ;
2+ import { List , Map } from 'immutable' ;
33import renderer from 'react-test-renderer' ;
4+ import { shallow } from 'enzyme' ;
45
56import { NotificationsRoute , mapStateToProps } from '../../routes/notifications' ;
67import { mockedNotificationsRecuderData } from '../../__mocks__/mockedData' ;
@@ -10,7 +11,8 @@ jest.mock('../../components/notifications');
1011describe ( 'routes/notification.js' , ( ) => {
1112 const props = {
1213 failed : false ,
13- accountNotifications : mockedNotificationsRecuderData
14+ accountNotifications : mockedNotificationsRecuderData ,
15+ hasNotifications : true ,
1416 } ;
1517
1618 it ( 'should test the mapStateToProps method' , ( ) => {
@@ -25,13 +27,43 @@ describe('routes/notification.js', () => {
2527
2628 expect ( mappedProps . failed ) . toBeFalsy ( ) ;
2729 expect ( mappedProps . accountNotifications ) . toEqual ( mockedNotificationsRecuderData ) ;
30+ expect ( mappedProps . hasNotifications ) . toBeTruthy ( ) ;
2831 } ) ;
2932
30- it ( 'should render itself & its children' , ( ) => {
33+ it ( 'should render itself & its children (with notifications) ' , ( ) => {
3134 const tree = renderer . create (
3235 < NotificationsRoute { ...props } />
3336 ) ;
3437
3538 expect ( tree ) . toMatchSnapshot ( ) ;
3639 } ) ;
40+
41+ it ( 'should render itself & its children (all read notifications)' , ( ) => {
42+ const caseProps = {
43+ ...props ,
44+ hasNotifications : false ,
45+ accountNotifications : List ( ) ,
46+ } ;
47+
48+ const wrapper = shallow (
49+ < NotificationsRoute { ...caseProps } />
50+ ) ;
51+
52+ expect ( wrapper ) . toBeDefined ( ) ;
53+ expect ( wrapper . find ( 'AllRead' ) ) . toHaveLength ( 1 ) ;
54+ } ) ;
55+
56+ it ( 'should render itself & its children (error page - oops)' , ( ) => {
57+ const caseProps = {
58+ ...props ,
59+ failed : true ,
60+ } ;
61+
62+ const wrapper = shallow (
63+ < NotificationsRoute { ...caseProps } />
64+ ) ;
65+
66+ expect ( wrapper ) . toBeDefined ( ) ;
67+ expect ( wrapper . find ( 'Oops' ) ) . toHaveLength ( 1 ) ;
68+ } ) ;
3769} ) ;
0 commit comments