@@ -94,4 +94,44 @@ describe("watchConfigurationChanges", () => {
9494 expect ( changes ) . toEqual ( [ [ "test.setting" ] ] ) ;
9595 dispose ( ) ;
9696 } ) ;
97+
98+ it ( "treats undefined, null, empty string, and empty array as equivalent" , ( ) => {
99+ const config = new MockConfigurationProvider ( ) ;
100+ config . set ( "test.setting" , undefined ) ;
101+ const { changes, dispose } = createWatcher ( "test.setting" ) ;
102+
103+ config . set ( "test.setting" , null ) ;
104+ config . set ( "test.setting" , "" ) ;
105+ config . set ( "test.setting" , [ ] ) ;
106+ config . set ( "test.setting" , undefined ) ;
107+
108+ expect ( changes ) . toEqual ( [ ] ) ;
109+ dispose ( ) ;
110+ } ) ;
111+
112+ interface ValueChangeTestCase {
113+ name : string ;
114+ from : unknown ;
115+ to : unknown ;
116+ }
117+
118+ it . each < ValueChangeTestCase > ( [
119+ { name : "undefined to value" , from : undefined , to : "value" } ,
120+ { name : "value to empty string" , from : "value" , to : "" } ,
121+ { name : "undefined to false" , from : undefined , to : false } ,
122+ { name : "undefined to zero" , from : undefined , to : 0 } ,
123+ { name : "null to value" , from : null , to : "value" } ,
124+ { name : "empty string to value" , from : "" , to : "value" } ,
125+ { name : "empty array to non-empty array" , from : [ ] , to : [ "item" ] } ,
126+ { name : "value to different value" , from : "old" , to : "new" } ,
127+ ] ) ( "detects change: $name" , ( { from, to } ) => {
128+ const config = new MockConfigurationProvider ( ) ;
129+ config . set ( "test.setting" , from ) ;
130+ const { changes, dispose } = createWatcher ( "test.setting" ) ;
131+
132+ config . set ( "test.setting" , to ) ;
133+
134+ expect ( changes ) . toEqual ( [ [ "test.setting" ] ] ) ;
135+ dispose ( ) ;
136+ } ) ;
97137} ) ;
0 commit comments