We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d8e4505 commit 7928dc2Copy full SHA for 7928dc2
test/unit/routes/login.test.ts
@@ -7,6 +7,19 @@ describe("login", () => {
7
expect(limiter.try()).toBe(true)
8
})
9
10
+ it("should pull tokens from both limiters (minute & hour)", () => {
11
+ const limiter = new RateLimiter()
12
+
13
+ // Try twice, which pulls two from the minute bucket
14
+ limiter.try()
15
16
17
+ // Check that we can still try
18
+ // which should be true since there are 12 remaining in the hour bucket
19
+ expect(limiter.canTry()).toBe(true)
20
+ expect(limiter.try()).toBe(true)
21
+ })
22
23
it("should not allow more than 14 tries in less than an hour", () => {
24
const limiter = new RateLimiter()
25
0 commit comments