1+ import { monthlyDashboardDataReducer } from '../monthlyDashboardDataReducer' ;
2+
3+ const monthlyDashboardData = {
4+ projectName : "" ,
5+ timeSpent_hrs : 0 ,
6+ }
7+
8+ describe ( 'Monthly Dashboard Data Reducer' , ( ) => {
9+
10+ it ( 'get monthly dashboard data' , ( ) => {
11+
12+ const newPayload = { projectName : 'Project Name' , timeSpent_hrs : '0' } ;
13+
14+ const action = {
15+ type : 'GET_MONTHLY_DASHBOARD_DATA' ,
16+ payload : newPayload ,
17+ } ;
18+
19+ const result = monthlyDashboardDataReducer ( monthlyDashboardData , action ) ;
20+ expect ( result ) . toEqual ( newPayload ) ;
21+
22+ } ) ;
23+
24+ it ( 'should return the initial state when an action type is not passed' , ( ) => {
25+
26+ const result = monthlyDashboardDataReducer ( monthlyDashboardData , { } ) ;
27+ expect ( result ) . toEqual ( monthlyDashboardData ) ;
28+
29+ } ) ;
30+
31+ it ( 'should return null as the initial state' , ( ) => {
32+
33+ const result = monthlyDashboardDataReducer ( undefined , { } ) ;
34+ expect ( result ) . toBeNull ( ) ;
35+
36+ } ) ;
37+
38+ it ( 'should return previous state if action type is unknown' , ( ) => {
39+ const action = {
40+ type : 'UNKNOWN_ACTION' ,
41+ payload : { projectName : 'Project Name' , timeSpent_hrs : '0' }
42+ } ;
43+
44+ const result = monthlyDashboardDataReducer ( monthlyDashboardData , action ) ;
45+ expect ( result ) . toEqual ( monthlyDashboardData ) ;
46+ } ) ;
47+
48+ } )
0 commit comments