@@ -82,7 +82,7 @@ describe('findClosest', () => {
8282 ] ) ( 'should attempt to find a closest match, $description' , ( { query, items } ) => {
8383 expect ( {
8484 query,
85- match : findClosest ( query , items as string [ ] )
85+ match : findClosest ( query , items as any )
8686 } ) . toMatchSnapshot ( ) ;
8787 } ) ;
8888
@@ -95,6 +95,36 @@ describe('findClosest', () => {
9595 findClosest ( 'button' , [ 'Button' , 'Badge' ] , { normalizeFn : throwingNormalizeFn } ) ;
9696 } ) . toThrow ( 'Normalization failed' ) ;
9797 } ) ;
98+
99+ it . each ( [
100+ {
101+ description : 'string query' ,
102+ query : 'button' ,
103+ items : [ 'Button' , 123 , 'Badge' ]
104+ } ,
105+ {
106+ description : 'number query' ,
107+ query : 123 ,
108+ items : [ 'Button' , 123 , 'Badge' ]
109+ } ,
110+ {
111+ description : 'number query with float' ,
112+ query : 123 ,
113+ items : [ 'Button' , 123.45 , 'Badge' ]
114+ } ,
115+ {
116+ description : 'float number query' ,
117+ query : 123.45 ,
118+ items : [ 'Button' , 123 , 'Badge' ]
119+ } ,
120+ {
121+ description : 'float against float query' ,
122+ query : 123.45 ,
123+ items : [ 'Button' , 123 , undefined , 123.44 , 'Badge' , null ]
124+ }
125+ ] ) ( 'should handle numbers in addition to strings, $description' , ( { query, items } ) => {
126+ expect ( findClosest ( query , items as any ) ) . toMatchSnapshot ( ) ;
127+ } ) ;
98128} ) ;
99129
100130describe ( 'fuzzySearch' , ( ) => {
@@ -312,7 +342,7 @@ describe('fuzzySearch', () => {
312342 }
313343 }
314344 ] ) ( 'should fuzzy match, $description' , ( { query, items, options } ) => {
315- expect ( fuzzySearch ( query , items as string [ ] , options ) ) . toMatchSnapshot ( ) ;
345+ expect ( fuzzySearch ( query , items as any , options ) ) . toMatchSnapshot ( ) ;
316346 } ) ;
317347
318348 it ( 'should handle normalizeFn errors in fuzzySearch' , ( ) => {
@@ -327,12 +357,12 @@ describe('fuzzySearch', () => {
327357
328358 it . each ( [
329359 {
330- description : 'string query with numbers ' ,
360+ description : 'string query' ,
331361 query : 'button' ,
332362 items : [ 'Button' , 123 , 'Badge' ]
333363 } ,
334364 {
335- description : 'exact number query with strings ' ,
365+ description : 'exact number query' ,
336366 query : 123 ,
337367 items : [ 'Button' , 123 , 'Badge' ]
338368 } ,
0 commit comments