@@ -593,6 +593,80 @@ describe('Test DrawSupport', () => {
593593 expect ( spyAddFeature . calls . length ) . toBe ( 1 ) ;
594594 } ) ;
595595
596+ it ( 'replace features no draw interaction' , ( ) => {
597+ const fakeMap = {
598+ addLayer : ( ) => { } ,
599+ disableEventListener : ( ) => { } ,
600+ enableEventListener : ( ) => { } ,
601+ addInteraction : ( ) => { } ,
602+ removeInteraction : ( ) => { } ,
603+ getInteractions : ( ) => ( {
604+ getLength : ( ) => 0
605+ } ) ,
606+ getView : ( ) => ( {
607+ getProjection : ( ) => ( {
608+ getCode : ( ) => 'EPSG:4326'
609+ } )
610+ } )
611+ } ;
612+ const feature = {
613+ type : 'Feature' ,
614+ geometry : {
615+ type : 'LineString' ,
616+ coordinates : [ [ 13 , 43 ] , [ 14 , 44 ] ]
617+ } ,
618+ properties : {
619+ 'name' : "some name"
620+ }
621+ } ;
622+
623+ const support = ReactDOM . render (
624+ < DrawSupport features = { [ ] } map = { fakeMap } /> , document . getElementById ( "container" ) ) ;
625+ expect ( support ) . toExist ( ) ;
626+ const spyAddInteraction = expect . spyOn ( support , "addInteractions" ) ;
627+ ReactDOM . render (
628+ < DrawSupport features = { [ feature ] } map = { fakeMap } drawStatus = "replace" drawMethod = "MultiLineString" options = { { drawEnabled : false } }
629+ /> , document . getElementById ( "container" ) ) ;
630+ expect ( spyAddInteraction . calls . length ) . toBe ( 0 ) ;
631+ } ) ;
632+
633+ it ( 'replace features with draw interaction' , ( ) => {
634+ const fakeMap = {
635+ addLayer : ( ) => { } ,
636+ disableEventListener : ( ) => { } ,
637+ enableEventListener : ( ) => { } ,
638+ addInteraction : ( ) => { } ,
639+ removeInteraction : ( ) => { } ,
640+ getInteractions : ( ) => ( {
641+ getLength : ( ) => 0
642+ } ) ,
643+ getView : ( ) => ( {
644+ getProjection : ( ) => ( {
645+ getCode : ( ) => 'EPSG:4326'
646+ } )
647+ } )
648+ } ;
649+ const feature = {
650+ type : 'Feature' ,
651+ geometry : {
652+ type : 'LineString' ,
653+ coordinates : [ [ 13 , 43 ] , [ 14 , 44 ] ]
654+ } ,
655+ properties : {
656+ 'name' : "some name"
657+ }
658+ } ;
659+
660+ const support = ReactDOM . render (
661+ < DrawSupport features = { [ ] } map = { fakeMap } /> , document . getElementById ( "container" ) ) ;
662+ expect ( support ) . toExist ( ) ;
663+ const spyAddInteraction = expect . spyOn ( support , "addInteractions" ) ;
664+ ReactDOM . render (
665+ < DrawSupport features = { [ feature ] } map = { fakeMap } drawStatus = "replace" drawMethod = "MultiLineString" options = { { drawEnabled : true } }
666+ /> , document . getElementById ( "container" ) ) ;
667+ expect ( spyAddInteraction . calls . length ) . toBe ( 1 ) ;
668+ } ) ;
669+
596670 it ( 'replace features circle' , ( ) => {
597671 const fakeMap = {
598672 addLayer : ( ) => { } ,
0 commit comments