Skip to content

Commit af37284

Browse files
Merge pull request #2998 from OneCommunityGlobal/aaryaneil-Unit-Test-userProjectMembersReducer
Aaryaneil Unit Tests for userProjectMembersReducer component
2 parents 82e9b76 + 2a740da commit af37284

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { userProjectMembersReducer } from "../userProjectMembersReducer";
2+
3+
describe("userProjectMembersReducer", () => {
4+
it("should return the initial state when no action is provided", () => {
5+
expect(userProjectMembersReducer(undefined, {})).toBe(null);
6+
});
7+
8+
it("should handle GET_USER_PROJECT_MEMBERS", () => {
9+
const action = {
10+
type: "GET_USER_PROJECT_MEMBERS",
11+
payload: [
12+
{ id: 1, name: "John Doe" },
13+
{ id: 2, name: "Jane Smith" },
14+
],
15+
};
16+
const expectedState = [
17+
{ id: 1, name: "John Doe" },
18+
{ id: 2, name: "Jane Smith" },
19+
];
20+
expect(userProjectMembersReducer(null, action)).toEqual(expectedState);
21+
});
22+
23+
it("should return the current state when an unknown action is provided", () => {
24+
const currentState = [
25+
{ id: 1, name: "John Doe" },
26+
{ id: 2, name: "Jane Smith" },
27+
];
28+
const action = { type: "UNKNOWN_ACTION" };
29+
expect(userProjectMembersReducer(currentState, action)).toBe(currentState);
30+
});
31+
});

0 commit comments

Comments
 (0)