import { Sort } from '../Sort' ; test ( 'Sort.compareByValue' , ( ) => { const array = [ 3 , 6 , 2 ] ; array . sort ( Sort . compareByValue ) ; } ) ; test ( 'Sort.compareByValue cases' , ( ) => { const values = [ undefined , null , - 1 , 1 ] ; const results = [ ] ; for ( let i = 0 ; i < values . length ; ++ i ) { for ( let j = 0 ; j < values . length ; ++ j ) { const x = values [ i ] ; const y = values [ j ] ; let relation = '?' ; switch ( Sort . compareByValue ( x , y ) ) { case - 1 : relation = '<' ; break ; case 0 : relation = '=' ; break ; case 1 : relation = '>' ; break ; } results . push ( `${ x } ${ relation } ${ y }` ) ; } } expect ( results ) . toMatchSnapshot ( ) ; } ) ; test ( 'Sort.sortBy' , ( ) => { const array = [ 'aaa' , 'bb' , 'c' ] ; Sort . sortBy ( array , ( x ) => x . length ) ; } ) ; test ( 'Sort.isSortedBy' , ( ) => { const array = [ 'a' , 'bb' , 'ccc' ] ; Sort . isSortedBy ( array , ( x ) => x . length ) ; } ) ; test ( 'Sort.sortMapKeys' , ( ) => { const map = new Map < string , number > ( ) ; map . set ( 'zebra' , 1 ) ; map . set ( 'goose' , 2 ) ; map . set ( 'aardvark' , 3 ) ; Sort . sortMapKeys ( map ) ; expect ( Array . from ( map . keys ( ) ) ) . toEqual ( [ 'aardvark' , 'goose' , 'zebra' ] ) ; } ) ; test ( 'Sort.sortSetBy' , ( ) => { const set = new Set < string > ( ) ; set . add ( 'aaa' ) ; set . add ( 'bb' ) ; set . add ( 'c' ) ; Sort . sortSetBy ( set , ( x ) => x . length ) ; expect ( Array . from ( set ) ) . toEqual ( [ 'c' , 'bb' , 'aaa' ] ) ; } ) ; test ( 'Sort.sortSet' , ( ) => { const set = new Set < string > ( ) ; set . add ( 'zebra' ) ; set . add ( 'goose' ) ; set . add ( 'aardvark' ) ; Sort . sortSet ( set ) ; expect ( Array . from ( set ) ) . toEqual ( [ 'aardvark' , 'goose' , 'zebra' ] ) ; } ) ;