Skip to content

Commit d308ba6

Browse files
Merge pull request #2893 from OneCommunityGlobal/sheetal-unit-test-monthly-dashboard-data-test
Sheetal M - Add unit test for monthlyDashboardDataReducer.js
2 parents 7ae9639 + bbda4bd commit d308ba6

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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

Comments
 (0)