| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,19 @@ describe("login", () => { | |||
| 7 | 7 | expect(limiter.try()).toBe(true) | |
| 8 | 8 | }) | |
| 9 | 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 | + limiter.try() | ||
| 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 | + | ||
| 10 | 23 | it("should not allow more than 14 tries in less than an hour", () => { | |
| 11 | 24 | const limiter = new RateLimiter() | |
| 12 | 25 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments