Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kpoke committed Feb 21, 2022
1 parent f4df1a5 commit aa88d39
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions server/__tests__/integration/capture/capture.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ describe('/captures', () => {
.send({ ...capture2, id: capture1.id })
.set('Accept', 'application/json')
.expect(204);
});

it('should confirm number of sent capture created events', async () => {
const numOfEmittedEvents = await knex('domain_event')
.count()
.where({ status: 'sent' });
expect(+numOfEmittedEvents[0].count).to.eql(2);
// added a timer to confirm this because the function call in the API is not 'awaited'
setTimeout(async () => {
const numOfEmittedEvents = await knex('domain_event')
.count()
.where({ status: 'sent' });
expect(+numOfEmittedEvents[0].count).to.eql(2);
}, 5000);
});

after(async () => {
Expand Down
13 changes: 7 additions & 6 deletions server/__tests__/integration/tree/tree.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ describe('/trees', () => {
.send({ ...tree2, id: tree1.id })
.set('Accept', 'application/json')
.expect(204);
});

it('should confirm number of sent capture created events', async () => {
const numOfEmittedEvents = await knex('domain_event')
.count()
.where({ status: 'sent' });
expect(+numOfEmittedEvents[0].count).to.eql(2);
// added a timer to confirm this because the function call in the API is not 'awaited'
setTimeout(async () => {
const numOfEmittedEvents = await knex('domain_event')
.count()
.where({ status: 'sent' });
expect(+numOfEmittedEvents[0].count).to.eql(2);
}, 5000);
});

after(async () => {
Expand Down

0 comments on commit aa88d39

Please sign in to comment.