Skip to content

Commit

Permalink
test: add tests for countJobs method in Pulse class
Browse files Browse the repository at this point in the history
  • Loading branch information
code-xhyun committed May 21, 2024
1 parent 92ec6dc commit a6e19e0
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/unit/pulse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,5 +339,42 @@ describe('Test Pulse', () => {
});
});
});

describe('Test countJobs', () => {
test('returns zero when there are no jobs', async () => {
const count = await globalPulseInstance.countJobs();
expect(count).toBe(0);
});

test('counts jobs correctly', async () => {
const job1 = globalPulseInstance.create('testJob1', {});
const job2 = globalPulseInstance.create('testJob2', {});
await job1.save();
await job2.save();

const count = await globalPulseInstance.countJobs();
expect(count).toBe(2);
});

test('counts jobs with query', async () => {
const job1 = globalPulseInstance.create('testJob1', { type: 'email' });
const job2 = globalPulseInstance.create('testJob2', { type: 'sms' });
await job1.save();
await job2.save();

const count = await globalPulseInstance.countJobs({ 'data.type': 'email' });
expect(count).toBe(1);
});

test('counts jobs with options', async () => {
const job1 = globalPulseInstance.create('testJob1', { type: 'email' });
const job2 = globalPulseInstance.create('testJob2', { type: 'sms' });
await job1.save();
await job2.save();

const count = await globalPulseInstance.countJobs({}, { limit: 1 });
expect(count).toBe(1);
});
});
});
});

1 comment on commit a6e19e0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 52%
54.7% (558/1020) 39.93% (121/303) 47.16% (75/159)

Pulse Test Report

Tests Skipped Failures Errors Time
60 0 💤 0 ❌ 0 🔥 8.932s ⏱️

Please sign in to comment.