import { DRAW_CARD_MAIN } from '../../src/constants/ActionTypes' ; import reducer from '../../src/reducers/cards' ; describe ( 'cards reducer' , ( ) => { it ( 'should return the initial state' , ( ) => { expect ( reducer ( undefined , { } as any ) ) . toEqual ( { total : { player : 0 , opponent : 0 } , list : [ ] , nextPos : { player : 0 , opponent : 0 } , } ) ; } ) ; it ( 'should handle DRAW_CARD_MAIN' , ( ) => { const before = { total : { player : 5 , opponent : 5 } , list : [ { position : 0 , n : 66 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'player' as const , } , null , { position : 1 , n : 1 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'player' as const , } , { position : 2 , n : 49 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'player' as const , } , { position : 3 , n : 98 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'player' as const , } , { position : 0 , n : 70 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'opponent' as const , } , null , { position : 2 , n : 8 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'opponent' as const , } , { position : - 2 , n : 39 , unusable : true , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'common' as const , } , { position : 3 , n : 73 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'opponent' as const , } , { n : 95 , position : 4 , owner : 'opponent' as const , unusable : true , discarded : false , isFlipped : false , zeroOpacity : false , } , { n : 27 , position : 4 , owner : 'player' as const , unusable : true , discarded : false , isFlipped : false , zeroOpacity : false , } , { n : 47 , position : 1 , owner : 'opponent' as const , unusable : true , discarded : false , isFlipped : false , zeroOpacity : false , } , { n : 54 , position : - 1 , owner : 'common' as const , unusable : true , discarded : false , isFlipped : true , zeroOpacity : false , } , ] , nextPos : { player : 1 , opponent : 3 } , } ; const after = { total : { player : 6 , opponent : 5 } , list : [ { position : 0 , n : 66 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'player' as const , } , null , { position : 2 , n : 1 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'player' as const , } , { position : 3 , n : 49 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'player' as const , } , { position : 4 , n : 98 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'player' as const , } , { position : 0 , n : 70 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'opponent' as const , } , null , { position : 2 , n : 8 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'opponent' as const , } , { position : - 2 , n : 39 , unusable : true , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'common' as const , } , { position : 3 , n : 73 , unusable : false , discarded : false , isFlipped : false , zeroOpacity : false , owner : 'opponent' as const , } , { n : 95 , position : 4 , owner : 'opponent' as const , unusable : true , discarded : false , isFlipped : false , zeroOpacity : false , } , { n : 27 , position : 5 , owner : 'player' as const , unusable : true , discarded : false , isFlipped : false , zeroOpacity : false , } , { n : 47 , position : 1 , owner : 'opponent' as const , unusable : true , discarded : false , isFlipped : false , zeroOpacity : false , } , { n : 54 , position : 1 , owner : 'player' as const , unusable : true , discarded : false , isFlipped : false , zeroOpacity : false , } , ] , nextPos : { player : 1 , opponent : 3 } , } ; expect ( reducer ( before , { type : DRAW_CARD_MAIN , owner : 'player' as const } ) ) . toEqual ( after ) ; } ) ; } ) ;