From 2697771a927471f07ce7e8f29ab37d6b5c3c3c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Susa=C3=B1a?= Date: Mon, 14 Oct 2024 18:32:45 -0400 Subject: [PATCH] fix(cooldown): tests --- packages/cooldown/src/manager.ts | 2 +- packages/cooldown/test/manager.test.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/cooldown/src/manager.ts b/packages/cooldown/src/manager.ts index 099bbcc..6362188 100644 --- a/packages/cooldown/src/manager.ts +++ b/packages/cooldown/src/manager.ts @@ -115,7 +115,7 @@ export class CooldownManager { target: string, props: CooldownProps, data: CooldownData, - use: keyof UsesProps, + use: keyof UsesProps = 'default', ): ReturnCache { const now = Date.now(); const deltaMS = now - data.lastDrip; diff --git a/packages/cooldown/test/manager.test.js b/packages/cooldown/test/manager.test.js index 9f3352f..af33b23 100644 --- a/packages/cooldown/test/manager.test.js +++ b/packages/cooldown/test/manager.test.js @@ -27,7 +27,9 @@ describe('CooldownManager', async () => { cooldownData = { type: CooldownType.User, interval: 1000, - uses: 3, + uses: { + default: 3 + }, }; handler.values = [ // @ts-expect-error @@ -48,7 +50,9 @@ describe('CooldownManager', async () => { assert.deepEqual(data, { type: CooldownType.User, interval: 1000, - uses: 3, + uses: { + default: 3 + } }); }); @@ -63,7 +67,7 @@ describe('CooldownManager', async () => { }); await test('has should return true when cooldown is active', () => { - for (let i = 0; i < cooldownData.uses; i++) { + for (let i = 0; i < cooldownData.uses.default; i++) { cooldownManager.use('testCommand', 'user1'); } const result = cooldownManager.has('testCommand', 'user1'); @@ -76,7 +80,7 @@ describe('CooldownManager', async () => { }); await test('use should return time left when cooldown is active', () => { - for (let i = 0; i < cooldownData.uses; i++) { + for (let i = 0; i < cooldownData.uses.default; i++) { cooldownManager.use('testCommand', 'user3'); } const result = cooldownManager.use('testCommand', 'user3');