@@ -272,10 +272,125 @@ describe('Test StatusBarService', () => {
272
272
const children = data [ 0 ] . children ! ;
273
273
expect ( children ) . toHaveLength ( 2 ) ;
274
274
expect ( children [ 0 ] ) . toEqual ( {
275
- ...pendingNode ,
275
+ ...fileNode ,
276
276
} ) ;
277
277
} ) ;
278
278
279
+ test ( 'Should in sort' , ( ) => {
280
+ const ignoreFolder = new TreeNodeModel ( {
281
+ id : 'ignore-folder' ,
282
+ fileType : FileTypes . Folder ,
283
+ name : '.git' ,
284
+ isLeaf : false ,
285
+ children : [ ] ,
286
+ } ) ;
287
+ const normalFolder = new TreeNodeModel ( {
288
+ id : 'nomral-folder' ,
289
+ fileType : FileTypes . Folder ,
290
+ name : 'folder' ,
291
+ isLeaf : false ,
292
+ children : [ ] ,
293
+ } ) ;
294
+ const normalFile = new TreeNodeModel ( {
295
+ id : 'nomral-file' ,
296
+ fileType : FileTypes . File ,
297
+ name : 'file' ,
298
+ isLeaf : true ,
299
+ children : [ ] ,
300
+ } ) ;
301
+ const ignoreFile = new TreeNodeModel ( {
302
+ id : 'ignore-file' ,
303
+ fileType : FileTypes . File ,
304
+ name : '.gitignore' ,
305
+ isLeaf : true ,
306
+ children : [ ] ,
307
+ } ) ;
308
+ const root = new TreeNodeModel ( {
309
+ id : 'root' ,
310
+ fileType : FileTypes . RootFolder ,
311
+ name : 'root-test' ,
312
+ isLeaf : false ,
313
+ children : [ ignoreFile , normalFile , normalFolder , ignoreFolder ] ,
314
+ } ) ;
315
+ folderTreeService . add ( root ) ;
316
+
317
+ // let data = folderTreeService.getState().folderTree?.data || [];
318
+ let rootNode = folderTreeService . get ( 'root' ) ! ;
319
+ expect ( rootNode . children ?. map ( ( i ) => i . name ) ) . toEqual ( [
320
+ '.git' ,
321
+ 'folder' ,
322
+ '.gitignore' ,
323
+ 'file' ,
324
+ ] ) ;
325
+
326
+ // add a file
327
+ folderTreeService . add (
328
+ new TreeNodeModel ( {
329
+ id : 'another-ignore-file' ,
330
+ fileType : FileTypes . File ,
331
+ name : '.prettierignore' ,
332
+ isLeaf : true ,
333
+ children : [ ] ,
334
+ } ) ,
335
+ 'root'
336
+ ) ;
337
+
338
+ rootNode = folderTreeService . get ( 'root' ) ! ;
339
+ expect ( rootNode . children ?. map ( ( i ) => i . name ) ) . toEqual ( [
340
+ '.git' ,
341
+ 'folder' ,
342
+ '.gitignore' ,
343
+ '.prettierignore' ,
344
+ 'file' ,
345
+ ] ) ;
346
+
347
+ // add a folder
348
+ folderTreeService . add (
349
+ new TreeNodeModel ( {
350
+ id : 'another-normal-folder' ,
351
+ fileType : FileTypes . Folder ,
352
+ name : 'another-folder' ,
353
+ isLeaf : false ,
354
+ children : [ ] ,
355
+ } ) ,
356
+ 'root'
357
+ ) ;
358
+
359
+ rootNode = folderTreeService . get ( 'root' ) ! ;
360
+ expect ( rootNode . children ?. map ( ( i ) => i . name ) ) . toEqual ( [
361
+ '.git' ,
362
+ 'another-folder' ,
363
+ 'folder' ,
364
+ '.gitignore' ,
365
+ '.prettierignore' ,
366
+ 'file' ,
367
+ ] ) ;
368
+
369
+ // add a input
370
+ folderTreeService . add (
371
+ new TreeNodeModel ( {
372
+ id : 'create-folder' ,
373
+ fileType : FileTypes . Folder ,
374
+ name : '' ,
375
+ isEditable : true ,
376
+ isLeaf : false ,
377
+ children : [ ] ,
378
+ } ) ,
379
+ 'root'
380
+ ) ;
381
+
382
+ rootNode = folderTreeService . get ( 'root' ) ! ;
383
+ expect ( rootNode . children ?. map ( ( i ) => i . name ) ) . toEqual ( [
384
+ '' ,
385
+ '.git' ,
386
+ 'another-folder' ,
387
+ 'folder' ,
388
+ '.gitignore' ,
389
+ '.prettierignore' ,
390
+ 'file' ,
391
+ ] ) ;
392
+ } ) ;
393
+
279
394
test ( 'Should support to set entry' , ( ) => {
280
395
folderTreeService . setEntry ( Button ) ;
281
396
expect ( folderTreeService . getState ( ) . entry ) . toEqual ( Button ) ;
0 commit comments