We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4683d8a commit 58e17c5Copy full SHA for 58e17c5
test/unit/routes/login.test.ts
@@ -0,0 +1,23 @@
1
+import { RateLimiter } from "../../../src/node/routes/login"
2
+
3
+describe("login", () => {
4
+ describe("RateLimiter", () => {
5
+ it("should allow one try ", () => {
6
+ const limiter = new RateLimiter()
7
+ expect(limiter.try()).toBe(true)
8
+ })
9
10
+ it("should not allow more than 14 tries in less than an hour", () => {
11
12
13
+ // The limiter allows 2 tries per minute plus 12 per hour
14
+ // so if we run it 15 times, 14 should return true and the last
15
+ // should return false
16
+ for (let i = 1; i <= 14; i++) {
17
18
+ }
19
20
+ expect(limiter.try()).toBe(false)
21
22
23
+})
0 commit comments