test: await portfolio publication done instead of polling ticks (WealthLedger/backend#63) (#103)
Backend verify / commits (push) Skipped
Backend verify / security (push) Successful in 13s
Backend verify / verify (push) Failing after 5m25s
Backend verify / commits (pull_request) Successful in 29s
Backend verify / security (pull_request) Successful in 11s
Backend verify / verify (pull_request) Successful in 4m39s
Backend verify / commits (push) Skipped
Backend verify / security (push) Successful in 13s
Backend verify / verify (push) Failing after 5m25s
Backend verify / commits (pull_request) Successful in 29s
Backend verify / security (pull_request) Successful in 11s
Backend verify / verify (pull_request) Successful in 4m39s
This commit was merged in pull request #103.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { setImmediate as immediate } from 'node:timers/promises';
|
||||
import assert from 'node:assert/strict';
|
||||
jest.mock('../../../../prisma/prisma.service', () => ({
|
||||
PrismaService: class {},
|
||||
}));
|
||||
@@ -97,14 +97,9 @@ describe('persistent portfolio projection', () => {
|
||||
],
|
||||
work: [],
|
||||
});
|
||||
await service.request('user', 'private', 'a');
|
||||
for (
|
||||
let index = 0;
|
||||
index < 10 && !repository.publish.mock.calls.length;
|
||||
index += 1
|
||||
) {
|
||||
await immediate();
|
||||
}
|
||||
const handle = await service.request('user', 'private', 'a');
|
||||
assert(handle);
|
||||
await handle.done;
|
||||
const snapshot = (
|
||||
repository.publish.mock.calls as [unknown, string, PortfolioDto][]
|
||||
)[0][2];
|
||||
@@ -147,10 +142,9 @@ describe('persistent portfolio projection', () => {
|
||||
{ units: '99' },
|
||||
{ currency: 'EUR', units: '1' },
|
||||
] });
|
||||
await service.request('user', 'private', 'a');
|
||||
for (let index = 0; index < 10 && !repository.publish.mock.calls.length; index++) {
|
||||
await immediate();
|
||||
}
|
||||
const handle = await service.request('user', 'private', 'a');
|
||||
assert(handle);
|
||||
await handle.done;
|
||||
const snapshot = (repository.publish.mock.calls as [unknown, string, PortfolioDto][])[0][2];
|
||||
expect(snapshot.cashBalances).toEqual([
|
||||
{ currency: 'RUB', value: '0' },
|
||||
|
||||
Reference in New Issue
Block a user