@@ -495,22 +495,41 @@ describe("__table", () => {
495495 } ) ;
496496
497497 it ( "__table sort" , ( ) => {
498- const operations1 = { ...EMPTY_TABLE_DATA . operations , sort : [ { column : "a" , direction : "desc" } ] } ;
498+ const operationsDesc = { ...EMPTY_TABLE_DATA . operations , sort : [ { column : "a" , direction : "desc" } ] } ;
499499 assert . deepStrictEqual (
500- __table ( source , operations1 ) ,
500+ __table ( source , operationsDesc ) ,
501501 [ { a : 3 , b : 6 , c : 9 } , { a : 2 , b : 4 , c : 6 } , { a : 1 , b : 2 , c : 3 } ]
502502 ) ;
503+ const operationsAsc = { ...EMPTY_TABLE_DATA . operations , sort : [ { column : "a" , direction : "asc" } ] } ;
504+ assert . deepStrictEqual (
505+ __table ( source , operationsAsc ) ,
506+ [ { a : 1 , b : 2 , c : 3 } , { a : 2 , b : 4 , c : 6 } , { a : 3 , b : 6 , c : 9 } ]
507+ ) ;
503508 const sourceExtended = [ ...source , { a : 1 , b : 3 , c : 3 } , { a : 1 , b : 5 , c : 3 } ] ;
504- const operations2 = {
509+ const operationsMulti = {
505510 ...EMPTY_TABLE_DATA . operations ,
506511 sort : [ { column : "a" , direction : "desc" } , { column : "b" , direction : "desc" } ]
507512 } ;
508513 assert . deepStrictEqual (
509- __table ( sourceExtended , operations2 ) ,
514+ __table ( sourceExtended , operationsMulti ) ,
510515 [ { a : 3 , b : 6 , c : 9 } , { a : 2 , b : 4 , c : 6 } , { a : 1 , b : 5 , c : 3 } , { a : 1 , b : 3 , c : 3 } , { a : 1 , b : 2 , c : 3 } ]
511516 ) ;
512517 } ) ;
513518
519+ it ( "__table sort missing values" , ( ) => {
520+ const sourceWithMissing = [ { a : 1 } , { a : null } , { a : undefined } , { a : 10 } , { a : 5 } , { a : NaN } , { a : null } , { a : 20 } ] ;
521+ const operationsDesc = { ...EMPTY_TABLE_DATA . operations , sort : [ { column : "a" , direction : "desc" } ] } ;
522+ assert . deepStrictEqual (
523+ __table ( sourceWithMissing , operationsDesc ) ,
524+ [ { a : 20 } , { a : 10 } , { a : 5 } , { a : 1 } , { a : null } , { a : undefined } , { a : NaN } , { a : null } ]
525+ ) ;
526+ const operationsAsc = { ...EMPTY_TABLE_DATA . operations , sort : [ { column : "a" , direction : "asc" } ] } ;
527+ assert . deepStrictEqual (
528+ __table ( sourceWithMissing , operationsAsc ) ,
529+ [ { a : 1 } , { a : 5 } , { a : 10 } , { a : 20 } , { a : null } , { a : undefined } , { a : NaN } , { a : null } ]
530+ ) ;
531+ } ) ;
532+
514533 it ( "__table sort does not mutate input" , ( ) => {
515534 const operations = { ...EMPTY_TABLE_DATA . operations , sort : [ { column : "a" , direction : "desc" } ] } ;
516535 assert . deepStrictEqual (
0 commit comments