11const chai = require ( 'chai' ) ;
2+ const chaiAsPromised = require ( "chai-as-promised" )
23const rewire = require ( "rewire" ) ;
34const index = require ( '../index' ) ;
45const main = rewire ( '../index' ) ;
56const expect = chai . expect ;
67chai . should ( ) ;
8+ chai . use ( chaiAsPromised ) ;
79
810describe ( 'asc & desc tests' , ( ) => {
911 let json0 , json1 , json2 , json3 ;
@@ -418,4 +420,30 @@ describe('typeOf()', () => {
418420 const should = main . __get__ ( "typeOf" ) ( given ) ;
419421 expect ( should ) . to . equal ( "STRING" ) ;
420422 } ) ;
423+ } ) ;
424+
425+ describe ( 'sortAsync' , ( ) => {
426+
427+ it ( 'given invalid object : should be rejected' , function ( ) {
428+ const given = "string" ;
429+ return index . sortAsync ( given ) . should . be . rejected ;
430+ } ) ;
431+
432+ describe ( 'given valid object : should sort successfully' , function ( ) {
433+ const given = { d : 1 , a : 0 } ;
434+ let result ;
435+
436+ before ( async ( ) => {
437+ result = await index . sortAsync ( given )
438+ } )
439+
440+ it ( 'expect key 1 to be a' , function ( ) {
441+ expect ( Object . keys ( result ) [ 0 ] ) . to . equal ( "a" )
442+ } ) ;
443+
444+ it ( 'expect key 2 to be d' , function ( ) {
445+ expect ( Object . keys ( result ) [ 1 ] ) . to . equal ( "d" )
446+ } ) ;
447+
448+ } ) ;
421449} ) ;
0 commit comments