@@ -4,20 +4,15 @@ import { Annotation, NewAnnotation } from '../../../@types';
44import { createAnnotationAction } from '../../annotations' ;
55import { mockContainerRect , mockRange } from '../__mocks__/data' ;
66import { Mode , toggleAnnotationModeAction } from '../../common' ;
7- import { resetCreatorAction } from '../../creator' ;
7+ import { CreatorStatus , resetCreatorAction , setStatusAction } from '../../creator' ;
88import { setIsPromotingAction , setSelectionAction , setIsSelectingAction } from '../actions' ;
99
1010describe ( 'store/highlight/reducer' , ( ) => {
1111 describe ( 'setIsPromoting' , ( ) => {
12- test . each `
13- payload | isPromoting | selection
14- ${ true } | ${ true } | ${ null }
15- ${ false } | ${ false } | ${ state . selection }
16- ` ( 'should set isPromoting and selection in state' , ( { isPromoting, payload, selection } ) => {
12+ test . each ( [ true , false ] ) ( 'should set isPromoting in state as %s' , payload => {
1713 const newState = reducer ( state , setIsPromotingAction ( payload ) ) ;
1814
19- expect ( newState . isPromoting ) . toEqual ( isPromoting ) ;
20- expect ( newState . selection ) . toEqual ( selection ) ;
15+ expect ( newState . isPromoting ) . toEqual ( payload ) ;
2116 } ) ;
2217 } ) ;
2318
@@ -64,4 +59,12 @@ describe('store/highlight/reducer', () => {
6459 expect ( newState . isPromoting ) . toEqual ( false ) ;
6560 } ) ;
6661 } ) ;
62+
63+ describe ( 'setStatusAction' , ( ) => {
64+ test ( 'should reset selection when creator status changes' , ( ) => {
65+ const newState = reducer ( state , setStatusAction ( CreatorStatus . started ) ) ;
66+
67+ expect ( newState . selection ) . toEqual ( null ) ;
68+ } ) ;
69+ } ) ;
6770} ) ;
0 commit comments