import { setEmsTmsDefaultModes } from './set_ems_tms_default_modes' ; describe ( 'setEmsTmsDefaultModes' , ( ) => { test ( 'Should handle missing layerListJSON attribute' , ( ) => { const attributes = { title : 'my map' , } ; expect ( setEmsTmsDefaultModes ( { attributes } ) ) . toEqual ( { title : 'my map' , } ) ; } ) ; test ( 'Should add lightModeDefault to existing EMS_TMS source descriptors' , ( ) => { const layerListJSON = JSON . stringify ( [ { sourceDescriptor : { type : 'EMS_TMS' , } , } , ] ) ; const attributes = { title : 'my map' , layerListJSON , } ; expect ( setEmsTmsDefaultModes ( { attributes } ) ) . toEqual ( { title : 'my map' , layerListJSON : '[{"sourceDescriptor":{"type":"EMS_TMS","lightModeDefault":"road_map"}}]' , } ) ; } ) ; test ( 'Should not change lightModeDefault if provided' , ( ) => { const layerListJSON = JSON . stringify ( [ { sourceDescriptor : { type : 'EMS_TMS' , lightModeDefault : 'road_map_desaturated' , } , } , ] ) ; const attributes = { title : 'my map' , layerListJSON , } ; expect ( setEmsTmsDefaultModes ( { attributes } ) ) . toEqual ( { title : 'my map' , layerListJSON : '[{"sourceDescriptor":{"type":"EMS_TMS","lightModeDefault":"road_map_desaturated"}}]' , } ) ; } ) ; } ) ;