11const chai = require ( 'chai' ) ;
2- const index = require ( './index' ) ;
2+ const rewire = require ( "rewire" ) ;
3+ const index = require ( '../index' ) ;
4+ const main = rewire ( '../index' ) ;
35const expect = chai . expect ;
46chai . should ( ) ;
57
@@ -357,9 +359,11 @@ describe('json array tests', () => {
357359 {
358360 dear : 3 ,
359361 abe : 4
360- }
362+ } ,
363+ "some string"
361364 ]
362- }
365+ } ,
366+ "some data"
363367 ] ;
364368 let result ;
365369
@@ -377,10 +381,41 @@ describe('json array tests', () => {
377381 expect ( Object . keys ( obj ) [ 0 ] ) . to . be . equal ( "boy" )
378382 } ) ;
379383
384+ it ( 'expect object 1.1 key 1 to be string' , function ( ) {
385+ const key = Object . keys ( result [ 1 ] ) [ 0 ] ;
386+ const actual = result [ 1 ] [ key ] [ 1 ] ;
387+ expect ( actual ) . to . equal ( "some string" )
388+ } ) ;
389+
380390 it ( 'expect object 1.0 [0] key 0 to be abe' , function ( ) {
381391 let key = Object . keys ( result [ 1 ] ) [ 0 ] ;
382392 let obj = result [ 1 ] [ key ] ;
383393 expect ( Object . keys ( obj [ 0 ] ) [ 0 ] ) . to . be . equal ( "abe" )
384394 } ) ;
395+
396+ it ( 'expect key 2 to be a string' , function ( ) {
397+ expect ( result [ 2 ] ) . to . equal ( "some data" )
398+ } ) ;
385399 } )
400+ } ) ;
401+
402+ describe ( 'sort()' , ( ) => {
403+ it ( 'given invalid object : should throw error' , function ( ) {
404+ const given = "string" ;
405+ try {
406+ const should = index . sort ( given ) ;
407+ expect . fail ( should ) ;
408+ } catch ( e ) {
409+ expect ( e . toString ( ) ) . to . equal ( "Error: must be an object/array" )
410+ }
411+ } ) ;
412+ } ) ;
413+
414+ describe ( 'typeOf()' , ( ) => {
415+
416+ it ( 'given any string : should return STRING' , function ( ) {
417+ const given = "any thing" ;
418+ const should = main . __get__ ( "typeOf" ) ( given ) ;
419+ expect ( should ) . to . equal ( "STRING" ) ;
420+ } ) ;
386421} ) ;
0 commit comments