@@ -19,7 +19,10 @@ import {
1919 htmlEscape ,
2020 repositionCaret ,
2121 isPending ,
22- validateThreadParams ,
22+ isPointLocationValid ,
23+ isHighlightLocationValid ,
24+ isDrawLocationValid ,
25+ areThreadParamsValid ,
2326 eventToLocationHandler ,
2427 decodeKeydown ,
2528 getHeaders ,
@@ -411,23 +414,64 @@ describe('annotatorUtil', () => {
411414 } ) ;
412415 } ) ;
413416
414- describe ( 'validateThreadParams ()' , ( ) => {
417+ describe ( 'isPointLocationValid ()' , ( ) => {
415418 it ( 'should return false if the thread is null or missing any expected params' , ( ) => {
416- expect ( validateThreadParams ( null ) ) . to . be . false ;
417- expect ( validateThreadParams ( { fileVersionId : 123 } ) ) . to . be . false ;
419+ expect ( isPointLocationValid ( { } ) ) . to . be . false ;
420+ expect ( isPointLocationValid ( { x : 1 , y : 2 } ) ) . to . be . true ;
418421 } ) ;
422+ } ) ;
419423
420- it ( 'should return true if the thread is has all expected params' , ( ) => {
424+ describe ( 'isHighlightLocationValid()' , ( ) => {
425+ it ( 'should return false if the thread is null or missing any expected params' , ( ) => {
426+ expect ( isHighlightLocationValid ( { } ) ) . to . be . false ;
427+ expect ( isHighlightLocationValid ( { quadPoints : { } } ) ) . to . be . true ;
428+ } ) ;
429+ } ) ;
430+
431+ describe ( 'isDrawLocationValid()' , ( ) => {
432+ it ( 'should return false if the thread is null or missing any expected params' , ( ) => {
433+ expect ( isDrawLocationValid ( { } ) ) . to . be . false ;
434+ expect ( isDrawLocationValid ( { minX : 1 , minY : 1 , maxX : 2 , maxY : 2 } ) ) . to . be . true ;
435+ } ) ;
436+ } ) ;
437+
438+ describe ( 'areThreadParamsValid()' , ( ) => {
439+ it ( 'should return false if the thread is null or missing any expected params' , ( ) => {
440+ expect ( areThreadParamsValid ( null ) ) . to . be . false ;
441+ expect ( areThreadParamsValid ( { fileVersionId : 123 } ) ) . to . be . false ;
442+ } ) ;
443+
444+ it ( 'should return false if thread has invalid location' , ( ) => {
421445 const threadParams = {
422446 annotatedElement : { } ,
423447 annotations : [ ] ,
424448 annotationService : { } ,
425449 fileVersionId : 123 ,
426450 location : { } ,
451+ locale : 'en-US'
452+ } ;
453+
454+ threadParams . type = TYPES . point ;
455+ expect ( areThreadParamsValid ( threadParams ) ) . to . be . false ;
456+
457+ threadParams . type = TYPES . highlight ;
458+ expect ( areThreadParamsValid ( threadParams ) ) . to . be . false ;
459+
460+ threadParams . type = TYPES . draw ;
461+ expect ( areThreadParamsValid ( threadParams ) ) . to . be . false ;
462+ } ) ;
463+
464+ it ( 'should return true if the thread is has all expected params' , ( ) => {
465+ const threadParams = {
466+ annotatedElement : { } ,
467+ annotations : [ ] ,
468+ annotationService : { } ,
469+ fileVersionId : 123 ,
470+ location : { x : 1 , y : 2 } ,
427471 locale : 'en-US' ,
428- type : ' point'
472+ type : TYPES . point
429473 } ;
430- expect ( validateThreadParams ( threadParams ) ) . to . be . true ;
474+ expect ( areThreadParamsValid ( threadParams ) ) . to . be . true ;
431475 } ) ;
432476 } ) ;
433477
0 commit comments