@@ -2621,7 +2621,7 @@ describe('CustomSortOrder.byMetadataFieldAlphabeticalReverse', () => {
26212621 } )
26222622} )
26232623
2624- describe ( 'sorterByMetadataField' , ( ) => {
2624+ describe ( 'sorterByMetadataField - string metadata ' , ( ) => {
26252625 it . each ( [
26262626 [ true , 'abc' , 'def' , - 1 , 'a' , 'a' ] ,
26272627 [ true , 'xyz' , 'klm' , 1 , 'b' , 'b' ] ,
@@ -2656,6 +2656,51 @@ describe('sorterByMetadataField', () => {
26562656 } )
26572657} )
26582658
2659+ describe ( 'sorterByMetadataField - boolean metadata' , ( ) => {
2660+ const ASC = true
2661+ const DESC = false
2662+ it . each ( [
2663+ [ ASC , true , false , 1 , 'a' , 'a' ] ,
2664+ [ ASC , false , true , - 1 , 'a' , 'a' ] ,
2665+ [ DESC , true , false , - 1 , 'a' , 'a' ] ,
2666+ [ DESC , false , true , 1 , 'a' , 'a' ] ,
2667+ [ ASC , true , undefined , - 1 , 'a' , 'a' ] ,
2668+ [ ASC , false , undefined , - 1 , 'a' , 'a' ] ,
2669+ [ DESC , true , undefined , - 1 , 'a' , 'a' ] ,
2670+ [ DESC , false , undefined , - 1 , 'a' , 'a' ] ,
2671+ [ ASC , undefined , true , 1 , 'a' , 'a' ] ,
2672+ [ ASC , undefined , false , 1 , 'a' , 'a' ] ,
2673+ [ DESC , undefined , true , 1 , 'a' , 'a' ] ,
2674+ [ DESC , undefined , false , 1 , 'a' , 'a' ] ,
2675+ [ ASC , true , true , EQUAL_OR_UNCOMPARABLE , 'a' , 'b' ] ,
2676+ [ ASC , false , false , EQUAL_OR_UNCOMPARABLE , 'a' , 'b' ] ,
2677+ [ DESC , true , true , EQUAL_OR_UNCOMPARABLE , 'a' , 'b' ] ,
2678+ [ DESC , false , false , EQUAL_OR_UNCOMPARABLE , 'a' , 'b' ] ,
2679+ [ ASC , true , 'false' , 1 , 'a' , 'a' ] ,
2680+ [ ASC , 'false' , true , - 1 , 'a' , 'a' ] ,
2681+ [ DESC , true , 'false' , - 1 , 'a' , 'a' ] ,
2682+ [ DESC , 'false' , true , 1 , 'a' , 'a' ] ,
2683+ [ ASC , 'true' , false , 1 , 'a' , 'a' ] ,
2684+ [ ASC , false , 'true' , - 1 , 'a' , 'a' ] ,
2685+ [ DESC , 'true' , false , - 1 , 'a' , 'a' ] ,
2686+ [ DESC , false , 'true' , 1 , 'a' , 'a' ] ,
2687+ [ ASC , true , 'true' , EQUAL_OR_UNCOMPARABLE , 'a' , 'b' ] ,
2688+ [ ASC , 'false' , false , EQUAL_OR_UNCOMPARABLE , 'a' , 'b' ] ,
2689+ [ DESC , 'true' , true , EQUAL_OR_UNCOMPARABLE , 'a' , 'b' ] ,
2690+ [ DESC , false , 'false' , EQUAL_OR_UNCOMPARABLE , 'a' , 'b' ] ,
2691+
2692+ ] ) ( 'straight order %s, comparing %s and %s should return %s for sortStrings %s and %s' ,
2693+ ( straight : boolean , metadataA : boolean | string | undefined , metadataB : boolean | string | undefined , order : number , sortStringA : string , sortStringB ) => {
2694+ const sorterFn = sorterByMetadataField ( ! straight , false )
2695+ const itemA : Partial < FolderItemForSorting > = { metadataFieldValue : metadataA as any , sortString : sortStringA }
2696+ const itemB : Partial < FolderItemForSorting > = { metadataFieldValue : metadataB as any , sortString : sortStringB }
2697+ const result = sorterFn ( itemA as FolderItemForSorting , itemB as FolderItemForSorting )
2698+
2699+ // then
2700+ expect ( result ) . toBe ( order )
2701+ } )
2702+ } )
2703+
26592704describe ( 'sorterByBookmarkOrder' , ( ) => {
26602705 it . each ( [
26612706 [ true , 10 , 20 , - 1 , 'a' , 'a' ] ,
0 commit comments