1- import { isFunction , isMissing , LOOSE_IDENTITY_COMPARATOR , wrapTryCatch } from './util' ;
1+ import { areEqualUsing , isFunction , isMissing , LOOSE_IDENTITY_COMPARATOR , wrapTryCatch } from './util' ;
2+ import { Comparator } from './types' ;
23
34describe ( isMissing . name , ( ) => {
45 it ( 'returns true for undefined' , ( ) => expect ( isMissing ( undefined ) ) . toBe ( true ) ) ;
@@ -73,4 +74,24 @@ describe(LOOSE_IDENTITY_COMPARATOR.name, () => {
7374 it ( `returns false for ${ a } / ${ b } ` ,
7475 ( ) => expect ( LOOSE_IDENTITY_COMPARATOR ( a , b ) ) . toBe ( false ) ) ;
7576 } ) ;
77+ } ) ;
78+
79+ describe ( areEqualUsing . name , ( ) => {
80+ const numericComparator : Comparator < number > = ( a , b ) => b - a ;
81+
82+ it ( 'returns true if a boolean comparator returns true' , ( ) =>
83+ expect ( areEqualUsing ( 42 , 42 , LOOSE_IDENTITY_COMPARATOR ) ) . toBe ( true )
84+ ) ;
85+
86+ it ( 'returns false if a boolean comparator returns false' , ( ) =>
87+ expect ( areEqualUsing ( 42 , 1337 , LOOSE_IDENTITY_COMPARATOR ) ) . toBe ( false )
88+ ) ;
89+
90+ it ( 'returns true if a numeric comparator returns 0' , ( ) =>
91+ expect ( areEqualUsing ( 42 , 42 , numericComparator ) ) . toBe ( true )
92+ ) ;
93+
94+ it ( 'returns false if a numeric comparator returns a non-zero value' , ( ) =>
95+ expect ( areEqualUsing ( 42 , 1337 , numericComparator ) ) . toBe ( false )
96+ ) ;
7697} ) ;
0 commit comments