Skip to content

Commit 2d125f9

Browse files
Merge pull request #2971 from OneCommunityGlobal/aaryaneil-unit-test-actionItemsReducer
Aaryaneil Unit Test actionItemsReducer
2 parents fd509ae + 41df1d4 commit 2d125f9

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { actionItemsReducer } from '../actionItemsReducer';
2+
3+
// Test initial state
4+
test('should return the initial state when no action is provided', () => {
5+
expect(actionItemsReducer(undefined, {})).toBeNull();
6+
});
7+
8+
// Test to handle of GET_ACTION_ITEMS action
9+
test('should handle GET_ACTION_ITEMS action', () => {
10+
const initialState = null;
11+
const action = {
12+
type: 'GET_ACTION_ITEMS',
13+
payload: [{ id: 1, name: 'Item 1' }, { id: 2, name: 'Item 2' }]
14+
};
15+
const expectedState = action.payload;
16+
17+
expect(actionItemsReducer(initialState, action)).toEqual(expectedState);
18+
});
19+
20+
// Test with an unknown action type
21+
test('should return current state for unknown action types', () => {
22+
const initialState = [{ id: 1, name: 'Item 1' }];
23+
const action = { type: 'UNKNOWN_ACTION' };
24+
25+
expect(actionItemsReducer(initialState, action)).toEqual(initialState);
26+
});

0 commit comments

Comments
 (0)