@@ -67,6 +67,17 @@ describe('Torrent Search API', () => {
6767 expect ( data . error ) . toBe ( 'Invalid limit. Must be a number.' ) ;
6868 } ) ;
6969
70+ it ( 'should return 400 for partial, fractional, or unsafe integer limits' , async ( ) => {
71+ for ( const limit of [ '10abc' , '1.5' , '9007199254740992' ] ) {
72+ const request = createRequest ( { q : 'test' , limit } ) ;
73+ const response = await GET ( request ) ;
74+
75+ expect ( response . status ) . toBe ( 400 ) ;
76+ const data = await response . json ( ) ;
77+ expect ( data . error ) . toBe ( 'Invalid limit. Must be a number.' ) ;
78+ }
79+ } ) ;
80+
7081 it ( 'should return 400 if limit exceeds maximum' , async ( ) => {
7182 const request = createRequest ( { q : 'test' , limit : '200' } ) ;
7283 const response = await GET ( request ) ;
@@ -94,6 +105,17 @@ describe('Torrent Search API', () => {
94105 expect ( data . error ) . toBe ( 'Invalid offset. Must be a number.' ) ;
95106 } ) ;
96107
108+ it ( 'should return 400 for partial, fractional, or unsafe integer offsets' , async ( ) => {
109+ for ( const offset of [ '10abc' , '1.5' , '9007199254740992' ] ) {
110+ const request = createRequest ( { q : 'test' , offset } ) ;
111+ const response = await GET ( request ) ;
112+
113+ expect ( response . status ) . toBe ( 400 ) ;
114+ const data = await response . json ( ) ;
115+ expect ( data . error ) . toBe ( 'Invalid offset. Must be a number.' ) ;
116+ }
117+ } ) ;
118+
97119 it ( 'should return 400 for negative offset' , async ( ) => {
98120 const request = createRequest ( { q : 'test' , offset : '-1' } ) ;
99121 const response = await GET ( request ) ;
0 commit comments