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