@@ -436,6 +436,86 @@ describe('SortingSpecProcessor', () => {
436436 } )
437437} )
438438
439+ const txtInputSimplistic1 : string = `
440+ target-folder: /*
441+ /:files
442+ //folders
443+ `
444+
445+ const expectedSortSpecForSimplistic1 : { [ key : string ] : CustomSortSpec } = {
446+ "/" : {
447+ groups : [ {
448+ filesOnly : true ,
449+ order : CustomSortOrder . alphabetical ,
450+ type : CustomSortGroupType . Outsiders
451+ } , {
452+ order : CustomSortOrder . alphabetical ,
453+ type : CustomSortGroupType . Outsiders
454+ } ] ,
455+ outsidersFilesGroupIdx : 0 ,
456+ outsidersGroupIdx : 1 ,
457+ targetFoldersPaths : [ '/*' ]
458+ }
459+ }
460+
461+ const expectedWildcardMatchingTreeForSimplistic1 = {
462+ "matchAll" : {
463+ groups : [ {
464+ filesOnly : true ,
465+ order : CustomSortOrder . alphabetical ,
466+ type : CustomSortGroupType . Outsiders
467+ } , {
468+ order : CustomSortOrder . alphabetical ,
469+ type : CustomSortGroupType . Outsiders
470+ } ] ,
471+ outsidersFilesGroupIdx : 0 ,
472+ outsidersGroupIdx : 1 ,
473+ targetFoldersPaths : [ '/*' ]
474+ } ,
475+ "subtree" : { }
476+ }
477+
478+ const txtInputSimplistic2 : string = `
479+ target-folder: /
480+ /:files
481+ //folders
482+ `
483+
484+ const expectedSortSpecForSimplistic2 : { [ key : string ] : CustomSortSpec } = {
485+ "/" : {
486+ groups : [ {
487+ filesOnly : true ,
488+ order : CustomSortOrder . alphabetical ,
489+ type : CustomSortGroupType . Outsiders
490+ } , {
491+ order : CustomSortOrder . alphabetical ,
492+ type : CustomSortGroupType . Outsiders
493+ } ] ,
494+ outsidersFilesGroupIdx : 0 ,
495+ outsidersGroupIdx : 1 ,
496+ targetFoldersPaths : [ '/' ]
497+ }
498+ }
499+
500+ describe ( 'SortingSpecProcessor' , ( ) => {
501+ let processor : SortingSpecProcessor ;
502+ beforeEach ( ( ) => {
503+ processor = new SortingSpecProcessor ( ) ;
504+ } ) ;
505+ it ( 'should recognize the simplistic sorting spec to put files first (wildcard /* rule)' , ( ) => {
506+ const inputTxtArr : Array < string > = txtInputSimplistic1 . split ( '\n' )
507+ const result = processor . parseSortSpecFromText ( inputTxtArr , 'mock-folder' , 'custom-name-note.md' )
508+ expect ( result ?. sortSpecByPath ) . toEqual ( expectedSortSpecForSimplistic1 )
509+ expect ( result ?. sortSpecByWildcard . tree ) . toEqual ( expectedWildcardMatchingTreeForSimplistic1 )
510+ } )
511+ it ( 'should recognize the simplistic sorting spec to put files first (direct / rule)' , ( ) => {
512+ const inputTxtArr : Array < string > = txtInputSimplistic2 . split ( '\n' )
513+ const result = processor . parseSortSpecFromText ( inputTxtArr , 'mock-folder' , 'custom-name-note.md' )
514+ expect ( result ?. sortSpecByPath ) . toEqual ( expectedSortSpecForSimplistic2 )
515+ expect ( result ?. sortSpecByWildcard ) . toBeUndefined ( )
516+ } )
517+ } )
518+
439519const txtInputItemsToHideWithDupsSortSpec : string = `
440520target-folder: AAA
441521/--hide: SomeFileToHide.md
0 commit comments