@@ -435,6 +435,48 @@ define([
435
435
assert . deepEqual ( testStore . actualData , expectedData ) ;
436
436
} ,
437
437
438
+ 'sorting with null and numbers' : function ( ) {
439
+ var store = new Memory ( {
440
+ data : [
441
+ { id : 1 , value : 1 } ,
442
+ { id : 2 , value : 2 } ,
443
+ { id : 3 , value : null } ,
444
+ { id : 4 , value : - 1 }
445
+ ]
446
+ } ) ;
447
+ var results = store . sort ( 'value' ) . fetchSync ( ) ;
448
+ assert . equal ( results [ 0 ] . id , 4 ) ;
449
+ assert . equal ( results [ 1 ] . id , 1 ) ;
450
+ assert . equal ( results [ 2 ] . id , 2 ) ;
451
+ assert . equal ( results [ 3 ] . id , 3 ) ;
452
+ var results = store . sort ( 'value' , true ) . fetchSync ( ) ;
453
+ assert . equal ( results [ 0 ] . id , 3 ) ;
454
+ assert . equal ( results [ 1 ] . id , 2 ) ;
455
+ assert . equal ( results [ 2 ] . id , 1 ) ;
456
+ assert . equal ( results [ 3 ] . id , 4 ) ;
457
+ } ,
458
+
459
+ 'sorting with null and strings' : function ( ) {
460
+ var store = new Memory ( {
461
+ data : [
462
+ { id : 1 , value : 'a' } ,
463
+ { id : 2 , value : 'b' } ,
464
+ { id : 3 , value : null } ,
465
+ { id : 4 , value : '' }
466
+ ]
467
+ } ) ;
468
+ var results = store . sort ( 'value' ) . fetchSync ( ) ;
469
+ assert . equal ( results [ 0 ] . id , 4 ) ;
470
+ assert . equal ( results [ 1 ] . id , 1 ) ;
471
+ assert . equal ( results [ 2 ] . id , 2 ) ;
472
+ assert . equal ( results [ 3 ] . id , 3 ) ;
473
+ var results = store . sort ( 'value' , true ) . fetchSync ( ) ;
474
+ assert . equal ( results [ 0 ] . id , 3 ) ;
475
+ assert . equal ( results [ 1 ] . id , 2 ) ;
476
+ assert . equal ( results [ 2 ] . id , 1 ) ;
477
+ assert . equal ( results [ 3 ] . id , 4 ) ;
478
+ } ,
479
+
438
480
nestedSuite : sorting ( 'dstore Memory sorting' , function before ( data ) {
439
481
return function before ( ) {
440
482
store = new Memory ( { data : data } ) ;
0 commit comments