diff --git a/src/modules/investments/portfolio/application/portfolio.service.spec.ts b/src/modules/investments/portfolio/application/portfolio.service.spec.ts index 2b12f43..008c160 100644 --- a/src/modules/investments/portfolio/application/portfolio.service.spec.ts +++ b/src/modules/investments/portfolio/application/portfolio.service.spec.ts @@ -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' },