@@ -5,7 +5,7 @@ import { rateLimit } from "./index.js";
55const mockRedis = {
66 get : vi . fn ( ) ,
77 expire : vi . fn ( ) ,
8- incrBy : vi . fn ( ) ,
8+ incrby : vi . fn ( ) ,
99} ;
1010
1111describe ( "rateLimit" , ( ) => {
@@ -14,7 +14,7 @@ describe("rateLimit", () => {
1414 vi . clearAllMocks ( ) ;
1515 mockRedis . get . mockReset ( ) ;
1616 mockRedis . expire . mockReset ( ) ;
17- mockRedis . incrBy . mockReset ( ) ;
17+ mockRedis . incrby . mockReset ( ) ;
1818 } ) ;
1919
2020 afterEach ( ( ) => {
@@ -52,7 +52,7 @@ describe("rateLimit", () => {
5252 rateLimit : 50 ,
5353 } ) ;
5454
55- expect ( mockRedis . incrBy ) . toHaveBeenCalledTimes ( 1 ) ;
55+ expect ( mockRedis . incrby ) . toHaveBeenCalledTimes ( 1 ) ;
5656 } ) ;
5757
5858 it ( "should rate limit if exceeded hard limit" , async ( ) => {
@@ -74,7 +74,7 @@ describe("rateLimit", () => {
7474 errorCode : "RATE_LIMIT_EXCEEDED" ,
7575 } ) ;
7676
77- expect ( mockRedis . incrBy ) . not . toHaveBeenCalled ( ) ;
77+ expect ( mockRedis . incrby ) . not . toHaveBeenCalled ( ) ;
7878 } ) ;
7979
8080 it ( "expires on the first incr request only" , async ( ) => {
@@ -92,7 +92,7 @@ describe("rateLimit", () => {
9292 requestCount : 2 ,
9393 rateLimit : 50 ,
9494 } ) ;
95- expect ( mockRedis . incrBy ) . toHaveBeenCalled ( ) ;
95+ expect ( mockRedis . incrby ) . toHaveBeenCalled ( ) ;
9696 } ) ;
9797
9898 it ( "enforces rate limit if sampled (hit)" , async ( ) => {
@@ -169,7 +169,7 @@ describe("rateLimit", () => {
169169 requestCount : 1 ,
170170 rateLimit : 50 ,
171171 } ) ;
172- expect ( mockRedis . incrBy ) . toHaveBeenCalledWith ( expect . any ( String ) , 1 ) ;
172+ expect ( mockRedis . incrby ) . toHaveBeenCalledWith ( expect . any ( String ) , 1 ) ;
173173 } ) ;
174174
175175 it ( "should handle null response from redis" , async ( ) => {
@@ -216,7 +216,7 @@ describe("rateLimit", () => {
216216 mockRedis . get . mockResolvedValue ( "0" ) ;
217217
218218 // Mock redis.set to have 100ms delay
219- mockRedis . incrBy . mockImplementation (
219+ mockRedis . incrby . mockImplementation (
220220 ( ) =>
221221 new Promise ( ( resolve ) => {
222222 setTimeout ( ( ) => resolve ( 1 ) , 100 ) ;
@@ -256,13 +256,13 @@ describe("rateLimit", () => {
256256 }
257257
258258 // Redis set should be called 3 times
259- expect ( mockRedis . incrBy ) . toHaveBeenCalledTimes ( 3 ) ;
259+ expect ( mockRedis . incrby ) . toHaveBeenCalledTimes ( 3 ) ;
260260 } ) ;
261261
262262 it ( "should handle custom increment values" , async ( ) => {
263263 // Mock initial state
264264 mockRedis . get . mockResolvedValue ( "5" ) ;
265- mockRedis . incrBy . mockResolvedValue ( 10 ) ;
265+ mockRedis . incrby . mockResolvedValue ( 10 ) ;
266266
267267 const result = await rateLimit ( {
268268 team : validTeamResponse ,
@@ -279,7 +279,7 @@ describe("rateLimit", () => {
279279 } ) ;
280280
281281 // Verify redis was called with correct increment
282- expect ( mockRedis . incrBy ) . toHaveBeenCalledWith (
282+ expect ( mockRedis . incrby ) . toHaveBeenCalledWith (
283283 expect . stringContaining ( "rate-limit" ) ,
284284 5 ,
285285 ) ;
0 commit comments