From 8b9dfab49b9f7ac1ac765ab47f84094dccf7c18a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrg=C3=BCn=20Day=C4=B1o=C4=9Flu?= Date: Sat, 6 Jul 2024 11:27:20 +0300 Subject: [PATCH] update for v5 --- test/global-rate-limit.test.js | 30 ++++++++++-------------------- test/route-rate-limit.test.js | 18 ++++++------------ 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/test/global-rate-limit.test.js b/test/global-rate-limit.test.js index ed1d082..78dcc7c 100644 --- a/test/global-rate-limit.test.js +++ b/test/global-rate-limit.test.js @@ -475,10 +475,8 @@ test('With redis store', async t => { t.equal(res.headers['x-ratelimit-remaining'], '1') t.equal(res.headers['x-ratelimit-reset'], '1') - t.teardown(async () => { - await redis.flushall() - await redis.quit() - }) + await redis.flushall() + await redis.quit() }) test('With redis store (ban)', async t => { @@ -531,10 +529,8 @@ test('With redis store (ban)', async t => { t.equal(res.headers['x-ratelimit-remaining'], '0') t.equal(res.headers['x-ratelimit-reset'], '1') - t.teardown(async () => { - await redis.flushall() - await redis.quit() - }) + await redis.flushall() + await redis.quit() }) test('Skip on redis error', async t => { @@ -1313,10 +1309,8 @@ test('When continue exceeding is on (Redis)', async t => { t.equal(second.headers['x-ratelimit-remaining'], '0') t.equal(second.headers['x-ratelimit-reset'], '5') - t.teardown(async () => { - await redis.flushall() - await redis.quit() - }) + await redis.flushall() + await redis.quit() }) test('Redis with continueExceeding should not always return the timeWindow as ttl', async t => { @@ -1372,10 +1366,8 @@ test('Redis with continueExceeding should not always return the timeWindow as tt t.equal(res.headers['x-ratelimit-remaining'], '0') t.equal(res.headers['x-ratelimit-reset'], '3') - t.teardown(async () => { - await redis.flushall() - await redis.quit() - }) + await redis.flushall() + await redis.quit() }) test('When use a custom nameSpace', async t => { @@ -1437,10 +1429,8 @@ test('When use a custom nameSpace', async t => { t.equal(res.headers['x-ratelimit-remaining'], '1') t.equal(res.headers['x-ratelimit-reset'], '1') - t.teardown(async () => { - await redis.flushall() - await redis.quit() - }) + await redis.flushall() + await redis.quit() }) test('on preHandler hook', async t => { diff --git a/test/route-rate-limit.test.js b/test/route-rate-limit.test.js index 6759081..1da31e5 100644 --- a/test/route-rate-limit.test.js +++ b/test/route-rate-limit.test.js @@ -364,10 +364,8 @@ test('With redis store', async t => { t.equal(res.headers['x-ratelimit-remaining'], '1') t.equal(res.headers['x-ratelimit-reset'], '1') - t.teardown(async () => { - await redis.flushall() - await redis.quit() - }) + await redis.flushall() + await redis.quit() }) test('Throw on redis error', async t => { @@ -1381,10 +1379,8 @@ test('When continue exceeding is on (Redis)', async t => { t.equal(second.headers['x-ratelimit-remaining'], '0') t.equal(second.headers['x-ratelimit-reset'], '5') - t.teardown(async () => { - await redis.flushall() - await redis.quit() - }) + await redis.flushall() + await redis.quit() }) test('When continue exceeding is off under route (Redis)', async t => { @@ -1435,10 +1431,8 @@ test('When continue exceeding is off under route (Redis)', async t => { t.equal(third.headers['x-ratelimit-remaining'], '0') t.equal(third.headers['x-ratelimit-reset'], '3') - t.teardown(async () => { - await redis.flushall() - await redis.quit() - }) + await redis.flushall() + await redis.quit() }) test('should consider routes allow list', async t => {