Skip to content

Commit

Permalink
fix(cooldown): tests
Browse files Browse the repository at this point in the history
  • Loading branch information
socram03 committed Oct 14, 2024
1 parent cf473ee commit 2697771
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/cooldown/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class CooldownManager {
target: string,
props: CooldownProps,
data: CooldownData,
use: keyof UsesProps,
use: keyof UsesProps = 'default',
): ReturnCache<boolean | number> {
const now = Date.now();
const deltaMS = now - data.lastDrip;
Expand Down
12 changes: 8 additions & 4 deletions packages/cooldown/test/manager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ describe('CooldownManager', async () => {
cooldownData = {
type: CooldownType.User,
interval: 1000,
uses: 3,
uses: {
default: 3
},
};
handler.values = [
// @ts-expect-error
Expand All @@ -48,7 +50,9 @@ describe('CooldownManager', async () => {
assert.deepEqual(data, {
type: CooldownType.User,
interval: 1000,
uses: 3,
uses: {
default: 3
}
});
});

Expand All @@ -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');
Expand All @@ -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');
Expand Down

0 comments on commit 2697771

Please sign in to comment.