Skip to content

Commit

Permalink
feat: added daily affected to tests for afeccted users
Browse files Browse the repository at this point in the history
  • Loading branch information
slaveeks committed Jan 20, 2025
1 parent c1506be commit c5ee977
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions workers/grouper/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ describe('GrouperWorker', () => {
await worker.handle(generateTask({ user: { id: '123' } }));

expect((await eventsCollection.findOne({})).usersAffected).toBe(1);
expect((await dailyEventsCollection.findOne({})).affectedUsers).toBe(1);
});

test('Should increment usersAffected count if users are different', async () => {
Expand All @@ -147,6 +148,7 @@ describe('GrouperWorker', () => {
await worker.handle(generateTask());

expect((await eventsCollection.findOne({})).usersAffected).toBe(4);
expect((await dailyEventsCollection.findOne({})).affectedUsers).toBe(4);
});

test('Should not increment usersAffected count if already there is error from that user', async () => {
Expand All @@ -156,6 +158,7 @@ describe('GrouperWorker', () => {
await worker.handle(generateTask({ user: { id: 'foo' } }));

expect((await eventsCollection.findOne({})).usersAffected).toBe(2);
expect((await dailyEventsCollection.findOne({})).affectedUsers).toBe(2);
});

test('Should increment usersAffected count if there is no user in original event', async () => {
Expand All @@ -165,6 +168,7 @@ describe('GrouperWorker', () => {
await worker.handle(generateTask({ user: { id: 'foo' } }));

expect((await eventsCollection.findOne({})).usersAffected).toBe(3);
expect((await dailyEventsCollection.findOne({})).affectedUsers).toBe(3);
});

test('Should not increment usersAffected count if there is no user in processed event', async () => {
Expand All @@ -174,6 +178,7 @@ describe('GrouperWorker', () => {
await worker.handle(generateTask({ user: { id: 'foo' } }));

expect((await eventsCollection.findOne({})).usersAffected).toBe(2);
expect((await dailyEventsCollection.findOne({})).affectedUsers).toBe(2);
});

test('Should stringify payload`s addons and context fields', async () => {
Expand Down

0 comments on commit c5ee977

Please sign in to comment.