@@ -29,13 +29,6 @@ const numberPagesTestParameters = [
2929 } ,
3030 // Not an Algolia behavior. Algolia returns an error:
3131 // "Value too small for \"hitsPerPage\" parameter, expected integer between 0 and 9223372036854775807",
32- {
33- hitsPerPage : - 1 ,
34- hitsLength : 20 ,
35- numberPages : 0 ,
36- } ,
37- // Not an Algolia behavior. Algolia returns an error:
38- // "Value too small for \"hitsPerPage\" parameter, expected integer between 0 and 9223372036854775807",
3932 {
4033 hitsPerPage : 1.5 ,
4134 hitsLength : 20 ,
@@ -129,15 +122,6 @@ const paginateHitsTestsParameters = [
129122 hitsPerPage : 0 ,
130123 returnedHits : [ ] ,
131124 } ,
132- // Wrong types
133- // Not an Algolia behavior. Algolia returns an error:
134- // "Value too small for \"hitsPerPage\" parameter, expected integer between 0 and 9223372036854775807",
135- {
136- hits : [ { id : 1 } , { id : 2 } , { id : 3 } ] ,
137- page : 0 ,
138- hitsPerPage : - 1 ,
139- returnedHits : [ ] ,
140- } ,
141125]
142126
143127describe . each ( numberPagesTestParameters ) (
@@ -163,3 +147,17 @@ describe.each(paginateHitsTestsParameters)(
163147 } )
164148 }
165149)
150+
151+ it ( 'Should throw when hitsPerPage is negative' , ( ) => {
152+ try {
153+ const hits : string [ ] = [ ]
154+ const hitsPerPage = - 1
155+ const page = 0
156+ adaptPagination ( hits , page , hitsPerPage )
157+ } catch ( e : any ) {
158+ expect ( e . message ) . toBe (
159+ 'Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807'
160+ )
161+ expect ( e . name ) . toBe ( 'TypeError' )
162+ }
163+ } )
0 commit comments