@@ -663,14 +663,16 @@ describe('Maps Client JS', () => {
663663 /**
664664 * Initialise geospatial maps helper
665665 */
666- function initialiseGeospatialMaps ( ) {
666+ function initialiseGeospatialMaps ( prefillFeatures = true ) {
667667 const input = document . body . querySelector ( 'textarea.govuk-textarea' )
668668 expect ( input ) . toBeDefined ( )
669669
670670 const geospatialInput = /** @type {HTMLInputElement } */ ( input )
671671
672672 // Set some initial values prior to initMaps
673- geospatialInput . value = JSON . stringify ( features , null , 2 )
673+ geospatialInput . value = prefillFeatures
674+ ? JSON . stringify ( features , null , 2 )
675+ : ''
674676
675677 expect ( ( ) => initMaps ( ) ) . not . toThrow ( )
676678 expect ( onMock ) . toHaveBeenCalledTimes ( 6 )
@@ -812,6 +814,15 @@ describe('Maps Client JS', () => {
812814 expect ( addMarkerMock ) . toHaveBeenCalledOnce ( )
813815 } )
814816
817+ test ( 'initMaps with no initial value' , ( ) => {
818+ initialiseGeospatialMaps ( false )
819+
820+ expect ( interactPlugin ) . toHaveBeenCalledWith ( expect . any ( Object ) )
821+ expect ( addPanelMock ) . toHaveBeenCalledWith ( 'info' , expect . any ( Object ) )
822+ expect ( addButtonMock ) . toHaveBeenCalledTimes ( 3 )
823+ expect ( interactPluginEnable ) . not . toHaveBeenCalled ( )
824+ } )
825+
815826 test ( 'drawing created' , ( ) => {
816827 const { geospatialInput } = initialiseGeospatialMaps ( )
817828
@@ -935,6 +946,8 @@ describe('Maps Client JS', () => {
935946 2
936947 )
937948 )
949+
950+ expectToggleButtons ( false , 3 )
938951 } )
939952
940953 test ( 'drawing deleted' , ( ) => {
0 commit comments