@@ -84,7 +84,40 @@ suite('ExtHostConfiguration', function () {
8484 assert . deepEqual ( config . get ( 'nested' ) , { config1 : 42 , config2 : 'Das Pferd frisst kein Reis.' } ) ;
8585 } ) ;
8686
87- test ( 'inspect' , function ( ) {
87+ test ( 'inspect in no workspace context' , function ( ) {
88+ const testObject = new ExtHostConfiguration (
89+ new class extends MainThreadConfigurationShape { } ,
90+ new ExtHostWorkspace ( new TestThreadService ( ) , null ) ,
91+ {
92+ defaults : new ConfigurationModel ( {
93+ 'editor' : {
94+ 'wordWrap' : 'off'
95+ }
96+ } , [ 'editor.wordWrap' ] ) ,
97+ user : new ConfigurationModel ( {
98+ 'editor' : {
99+ 'wordWrap' : 'on'
100+ }
101+ } , [ 'editor.wordWrap' ] ) ,
102+ workspace : new ConfigurationModel ( { } , [ ] ) ,
103+ folders : Object . create ( null )
104+ }
105+ ) ;
106+
107+ let actual = testObject . getConfiguration ( ) . inspect ( 'editor.wordWrap' ) ;
108+ assert . equal ( actual . defaultValue , 'off' ) ;
109+ assert . equal ( actual . globalValue , 'on' ) ;
110+ assert . equal ( actual . workspaceValue , undefined ) ;
111+ assert . ok ( Object . keys ( actual ) . indexOf ( 'folderValue' ) === - 1 ) ;
112+
113+ actual = testObject . getConfiguration ( 'editor' ) . inspect ( 'wordWrap' ) ;
114+ assert . equal ( actual . defaultValue , 'off' ) ;
115+ assert . equal ( actual . globalValue , 'on' ) ;
116+ assert . equal ( actual . workspaceValue , undefined ) ;
117+ assert . ok ( Object . keys ( actual ) . indexOf ( 'folderValue' ) === - 1 ) ;
118+ } ) ;
119+
120+ test ( 'inspect in single root context' , function ( ) {
88121 const workspaceUri = URI . file ( 'foo' ) ;
89122 const folders = Object . create ( null ) ;
90123 const workspace = new ConfigurationModel ( {
@@ -116,10 +149,140 @@ suite('ExtHostConfiguration', function () {
116149 }
117150 ) ;
118151
119- const actual = testObject . getConfiguration ( ) . inspect ( 'editor.wordWrap' ) ;
120- assert . equal ( actual . defaultValue , 'off' ) ;
121- assert . equal ( actual . globalValue , 'on' ) ;
122- assert . equal ( actual . workspaceValue , 'bounded' ) ;
152+ let actual1 = testObject . getConfiguration ( ) . inspect ( 'editor.wordWrap' ) ;
153+ assert . equal ( actual1 . defaultValue , 'off' ) ;
154+ assert . equal ( actual1 . globalValue , 'on' ) ;
155+ assert . equal ( actual1 . workspaceValue , 'bounded' ) ;
156+ assert . ok ( Object . keys ( actual1 ) . indexOf ( 'folderValue' ) === - 1 ) ;
157+
158+ actual1 = testObject . getConfiguration ( 'editor' ) . inspect ( 'wordWrap' ) ;
159+ assert . equal ( actual1 . defaultValue , 'off' ) ;
160+ assert . equal ( actual1 . globalValue , 'on' ) ;
161+ assert . equal ( actual1 . workspaceValue , 'bounded' ) ;
162+ assert . ok ( Object . keys ( actual1 ) . indexOf ( 'folderValue' ) === - 1 ) ;
163+
164+ let actual2 = testObject . getConfiguration2 ( null , workspaceUri ) . inspect ( 'editor.wordWrap' ) ;
165+ assert . equal ( actual2 . defaultValue , 'off' ) ;
166+ assert . equal ( actual2 . globalValue , 'on' ) ;
167+ assert . equal ( actual2 . workspaceValue , 'bounded' ) ;
168+ assert . equal ( actual2 . folderValue , 'bounded' ) ;
169+
170+ actual2 = testObject . getConfiguration2 ( 'editor' , workspaceUri ) . inspect ( 'wordWrap' ) ;
171+ assert . equal ( actual2 . defaultValue , 'off' ) ;
172+ assert . equal ( actual2 . globalValue , 'on' ) ;
173+ assert . equal ( actual2 . workspaceValue , 'bounded' ) ;
174+ assert . equal ( actual2 . folderValue , 'bounded' ) ;
175+ } ) ;
176+
177+ test ( 'inspect in multi root context' , function ( ) {
178+ const workspace = new ConfigurationModel ( {
179+ 'editor' : {
180+ 'wordWrap' : 'bounded'
181+ }
182+ } , [ 'editor.wordWrap' ] ) ;
183+
184+ const firstRoot = URI . file ( 'foo1' ) ;
185+ const secondRoot = URI . file ( 'foo2' ) ;
186+ const thirdRoot = URI . file ( 'foo3' ) ;
187+ const folders = Object . create ( null ) ;
188+ folders [ firstRoot . toString ( ) ] = new ConfigurationModel ( {
189+ 'editor' : {
190+ 'wordWrap' : 'off' ,
191+ 'lineNumbers' : 'relative'
192+ }
193+ } , [ 'editor.wordWrap' ] ) ;
194+ folders [ secondRoot . toString ( ) ] = new ConfigurationModel ( {
195+ 'editor' : {
196+ 'wordWrap' : 'on'
197+ }
198+ } , [ 'editor.wordWrap' ] ) ;
199+ folders [ thirdRoot . toString ( ) ] = new ConfigurationModel ( { } , [ ] ) ;
200+
201+ const testObject = new ExtHostConfiguration (
202+ new class extends MainThreadConfigurationShape { } ,
203+ new ExtHostWorkspace ( new TestThreadService ( ) , {
204+ 'id' : 'foo' ,
205+ 'roots' : [ firstRoot , secondRoot ] ,
206+ 'name' : 'foo'
207+ } ) ,
208+ {
209+ defaults : new ConfigurationModel ( {
210+ 'editor' : {
211+ 'wordWrap' : 'off' ,
212+ 'lineNumbers' : 'on'
213+ }
214+ } , [ 'editor.wordWrap' ] ) ,
215+ user : new ConfigurationModel ( {
216+ 'editor' : {
217+ 'wordWrap' : 'on'
218+ }
219+ } , [ 'editor.wordWrap' ] ) ,
220+ workspace,
221+ folders
222+ }
223+ ) ;
224+
225+ let actual1 = testObject . getConfiguration ( ) . inspect ( 'editor.wordWrap' ) ;
226+ assert . equal ( actual1 . defaultValue , 'off' ) ;
227+ assert . equal ( actual1 . globalValue , 'on' ) ;
228+ assert . equal ( actual1 . workspaceValue , 'off' ) ;
229+ assert . ok ( Object . keys ( actual1 ) . indexOf ( 'folderValue' ) === - 1 ) ;
230+
231+ actual1 = testObject . getConfiguration ( 'editor' ) . inspect ( 'wordWrap' ) ;
232+ assert . equal ( actual1 . defaultValue , 'off' ) ;
233+ assert . equal ( actual1 . globalValue , 'on' ) ;
234+ assert . equal ( actual1 . workspaceValue , 'off' ) ;
235+ assert . ok ( Object . keys ( actual1 ) . indexOf ( 'folderValue' ) === - 1 ) ;
236+
237+ actual1 = testObject . getConfiguration ( 'editor' ) . inspect ( 'lineNumbers' ) ;
238+ assert . equal ( actual1 . defaultValue , 'on' ) ;
239+ assert . equal ( actual1 . globalValue , undefined ) ;
240+ assert . equal ( actual1 . workspaceValue , 'relative' ) ;
241+ assert . ok ( Object . keys ( actual1 ) . indexOf ( 'folderValue' ) === - 1 ) ;
242+
243+ let actual2 = testObject . getConfiguration2 ( null , firstRoot ) . inspect ( 'editor.wordWrap' ) ;
244+ assert . equal ( actual2 . defaultValue , 'off' ) ;
245+ assert . equal ( actual2 . globalValue , 'on' ) ;
246+ assert . equal ( actual2 . workspaceValue , 'bounded' ) ;
247+ assert . equal ( actual2 . folderValue , 'off' ) ;
248+
249+ actual2 = testObject . getConfiguration2 ( 'editor' , firstRoot ) . inspect ( 'wordWrap' ) ;
250+ assert . equal ( actual2 . defaultValue , 'off' ) ;
251+ assert . equal ( actual2 . globalValue , 'on' ) ;
252+ assert . equal ( actual2 . workspaceValue , 'bounded' ) ;
253+ assert . equal ( actual2 . folderValue , 'off' ) ;
254+
255+ actual2 = testObject . getConfiguration2 ( 'editor' , firstRoot ) . inspect ( 'lineNumbers' ) ;
256+ assert . equal ( actual2 . defaultValue , 'on' ) ;
257+ assert . equal ( actual2 . globalValue , undefined ) ;
258+ assert . equal ( actual2 . workspaceValue , undefined ) ;
259+ assert . equal ( actual2 . folderValue , 'relative' ) ;
260+
261+ actual2 = testObject . getConfiguration2 ( null , secondRoot ) . inspect ( 'editor.wordWrap' ) ;
262+ assert . equal ( actual2 . defaultValue , 'off' ) ;
263+ assert . equal ( actual2 . globalValue , 'on' ) ;
264+ assert . equal ( actual2 . workspaceValue , 'bounded' ) ;
265+ assert . equal ( actual2 . folderValue , 'on' ) ;
266+
267+ actual2 = testObject . getConfiguration2 ( 'editor' , secondRoot ) . inspect ( 'wordWrap' ) ;
268+ assert . equal ( actual2 . defaultValue , 'off' ) ;
269+ assert . equal ( actual2 . globalValue , 'on' ) ;
270+ assert . equal ( actual2 . workspaceValue , 'bounded' ) ;
271+ assert . equal ( actual2 . folderValue , 'on' ) ;
272+
273+ actual2 = testObject . getConfiguration2 ( null , thirdRoot ) . inspect ( 'editor.wordWrap' ) ;
274+ assert . equal ( actual2 . defaultValue , 'off' ) ;
275+ assert . equal ( actual2 . globalValue , 'on' ) ;
276+ assert . equal ( actual2 . workspaceValue , 'bounded' ) ;
277+ assert . ok ( Object . keys ( actual2 ) . indexOf ( 'folderValue' ) !== - 1 ) ;
278+ assert . equal ( actual2 . folderValue , undefined ) ;
279+
280+ actual2 = testObject . getConfiguration2 ( 'editor' , thirdRoot ) . inspect ( 'wordWrap' ) ;
281+ assert . equal ( actual2 . defaultValue , 'off' ) ;
282+ assert . equal ( actual2 . globalValue , 'on' ) ;
283+ assert . equal ( actual2 . workspaceValue , 'bounded' ) ;
284+ assert . ok ( Object . keys ( actual2 ) . indexOf ( 'folderValue' ) !== - 1 ) ;
285+ assert . equal ( actual2 . folderValue , undefined ) ;
123286 } ) ;
124287
125288 test ( 'getConfiguration vs get' , function ( ) {
0 commit comments