@@ -11,6 +11,17 @@ import {
1111} from '../actions' ;
1212
1313describe ( 'store/annotations/reducer' , ( ) => {
14+ const getAnnotation = ( ) : AnnotationDrawing => {
15+ return {
16+ id : 'anno_1' ,
17+ target : {
18+ path_groups : [ { paths : [ { points : [ ] } ] , stroke : { color : '#000' , size : 1 } } ] as Array < PathGroup > ,
19+ type : 'drawing' ,
20+ } ,
21+ type : 'annotation' ,
22+ } as AnnotationDrawing ;
23+ } ;
24+
1425 describe ( 'setIsInitialized' , ( ) => {
1526 test ( 'should set isInitialized' , ( ) => {
1627 const newState = reducer ( state , setIsInitialized ( ) ) ;
@@ -28,9 +39,27 @@ describe('store/annotations/reducer', () => {
2839 expect ( newState . allIds ) . toContain ( payload . id ) ;
2940 expect ( newState . byId . anno_1 ) . toEqual ( payload ) ;
3041 } ) ;
42+
43+ test ( 'should set format drawing if drawing type annotation' , ( ) => {
44+ const arg = { } as NewAnnotation ;
45+ const payload = getAnnotation ( ) ;
46+ const newState = reducer ( state , createAnnotationAction . fulfilled ( payload , 'test' , arg ) ) ;
47+
48+ expect ( newState . allIds ) . toContain ( payload . id ) ;
49+ expect ( newState . byId . anno_1 ) . toMatchObject ( {
50+ target : {
51+ path_groups : [
52+ {
53+ clientId : expect . any ( String ) ,
54+ paths : [ { clientId : expect . any ( String ) } ] ,
55+ } ,
56+ ] ,
57+ } ,
58+ } ) ;
59+ } ) ;
3160 } ) ;
3261
33- describe ( 'createAnnotationAction ' , ( ) => {
62+ describe ( 'fetchAnnotationsAction ' , ( ) => {
3463 test ( 'should set state when fulfilled' , ( ) => {
3564 const annotation = { id : 'anno_1' , target : { type : 'region' } , type : 'annotation' } ;
3665 const payload = { entries : [ annotation ] , limit : 1000 , next_marker : null } as APICollection < Annotation > ;
@@ -42,14 +71,7 @@ describe('store/annotations/reducer', () => {
4271 } ) ;
4372
4473 test ( 'should format drawing when target is drawing type' , ( ) => {
45- const annotation = {
46- id : 'anno_1' ,
47- target : {
48- path_groups : [ { paths : [ { points : [ ] } ] , stroke : { color : '#000' , size : 1 } } ] as Array < PathGroup > ,
49- type : 'drawing' ,
50- } ,
51- type : 'annotation' ,
52- } as AnnotationDrawing ;
74+ const annotation = getAnnotation ( ) ;
5375 const payload = { entries : [ annotation ] , limit : 1000 , next_marker : null } as APICollection < Annotation > ;
5476 const newState = reducer ( state , fetchAnnotationsAction . fulfilled ( payload , 'test' , undefined ) ) ;
5577
0 commit comments