@@ -334,11 +334,19 @@ describe("A Body", function () {
334334 expect ( body . collection . at ( 0 ) . get ( "id" ) ) . toBe ( 1 ) ;
335335 expect ( body . collection . at ( 1 ) . get ( "id" ) ) . toBe ( 2 ) ;
336336
337+ var onBackgridSortedCallArgs = [ ] ;
338+ col . on ( "backgrid:sorted" , function ( ) {
339+ onBackgridSortedCallArgs . push ( [ ] . slice . apply ( arguments ) ) ;
340+ } ) ;
341+
337342 body . collection . trigger ( "backgrid:sort" , body . columns . at ( 0 ) , "descending" ) ;
338343
339344 expect ( body . collection . at ( 0 ) . get ( "id" ) ) . toBe ( 2 ) ;
340345 expect ( body . collection . at ( 1 ) . get ( "id" ) ) . toBe ( 1 ) ;
341346 expect ( body . columns . at ( 0 ) . get ( "direction" ) , "descending" ) ;
347+ expect ( onBackgridSortedCallArgs . length ) . toBe ( 1 ) ;
348+ expect ( onBackgridSortedCallArgs [ 0 ] [ 0 ] ) . toBe ( body . columns . at ( 0 ) ) ;
349+ expect ( onBackgridSortedCallArgs [ 0 ] [ 1 ] ) . toBe ( "descending" ) ;
342350
343351 $ . ajax = oldAjax ;
344352 } ) ;
@@ -365,31 +373,42 @@ describe("A Body", function () {
365373
366374 body . render ( ) ;
367375
368- col . trigger ( "backgrid:sort" , body . columns . at ( 0 ) , "ascending" ) ;
376+ var onBackgridSortedCallArgs = [ ] ;
377+ col . on ( "backgrid:sorted" , function ( ) {
378+ onBackgridSortedCallArgs . push ( [ ] . slice . apply ( arguments ) ) ;
379+ } ) ;
369380
381+ col . trigger ( "backgrid:sort" , body . columns . at ( 0 ) , "ascending" ) ;
370382 expect ( body . collection . toJSON ( ) ) . toEqual ( [ { id : 3 } ] ) ;
371383 expect ( body . columns . at ( 0 ) . get ( "direction" ) , "ascending" ) ;
384+ expect ( onBackgridSortedCallArgs . length ) . toBe ( 1 ) ;
385+ expect ( onBackgridSortedCallArgs [ 0 ] [ 0 ] ) . toBe ( body . columns . at ( 0 ) ) ;
386+ expect ( onBackgridSortedCallArgs [ 0 ] [ 1 ] ) . toBe ( "ascending" ) ;
387+ expect ( onBackgridSortedCallArgs [ 0 ] [ 2 ] ) . toBe ( col ) ;
372388
373389 body . collection . getPage ( 2 ) ;
374-
375390 expect ( body . collection . toJSON ( ) ) . toEqual ( [ { id : 2 } ] ) ;
376391
377392 body . collection . getPage ( 3 ) ;
378-
379393 expect ( body . collection . toJSON ( ) ) . toEqual ( [ { id : 1 } ] ) ;
380394
381395 body . collection . getFirstPage ( ) ;
382396
383397 col . trigger ( "backgrid:sort" , body . columns . at ( 0 ) , "descending" ) ;
384398 expect ( body . columns . at ( 0 ) . get ( "direction" ) , "descending" ) ;
385-
386399 expect ( body . collection . toJSON ( ) ) . toEqual ( [ { id : 1 } ] ) ;
400+ expect ( onBackgridSortedCallArgs . length ) . toBe ( 2 ) ;
401+ expect ( onBackgridSortedCallArgs [ 1 ] [ 0 ] ) . toBe ( body . columns . at ( 0 ) ) ;
402+ expect ( onBackgridSortedCallArgs [ 1 ] [ 1 ] ) . toBe ( "descending" ) ;
403+ expect ( onBackgridSortedCallArgs [ 1 ] [ 2 ] ) . toBe ( col ) ;
387404
388405 col . trigger ( "backgrid:sort" , body . columns . at ( 0 ) , null ) ;
389406 expect ( body . columns . at ( 0 ) . get ( "direction" ) , null ) ;
390-
391407 expect ( body . collection . toJSON ( ) ) . toEqual ( [ { id : 2 } ] ) ;
392-
408+ expect ( onBackgridSortedCallArgs . length ) . toBe ( 3 ) ;
409+ expect ( onBackgridSortedCallArgs [ 2 ] [ 0 ] ) . toBe ( body . columns . at ( 0 ) ) ;
410+ expect ( onBackgridSortedCallArgs [ 2 ] [ 1 ] ) . toBe ( null ) ;
411+ expect ( onBackgridSortedCallArgs [ 2 ] [ 2 ] ) . toBe ( col ) ;
393412 } ) ;
394413
395414 it ( "will put the next editable and renderable cell in edit mode when a save or one of the navigation commands is triggered via backgrid:edited from the collection" , function ( ) {
0 commit comments