From 5cfc7e8948e94bef05125c2292d56511113dbc48 Mon Sep 17 00:00:00 2001 From: Evyatar Date: Mon, 27 Nov 2023 19:58:25 +0200 Subject: [PATCH] tests(vest): Async isolate done callback --- .../suiteResult/done/__tests__/done.test.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/packages/vest/src/suiteResult/done/__tests__/done.test.ts b/packages/vest/src/suiteResult/done/__tests__/done.test.ts index 5eee29638..fa0edf7b7 100644 --- a/packages/vest/src/suiteResult/done/__tests__/done.test.ts +++ b/packages/vest/src/suiteResult/done/__tests__/done.test.ts @@ -373,4 +373,42 @@ describe('done', () => { expect(cb).not.toHaveBeenCalled(); }); }); + + describe('Async Isolate', () => { + describe('When async isolate is pending', () => { + it('Should not call the callback', () => { + const cb = jest.fn(); + + const suite = vest.create(() => { + vest.test('test', () => false); + + vest.group('group', async () => { + await wait(1000); + }); + }); + + suite().done(cb); + + expect(cb).not.toHaveBeenCalled(); + }); + }); + + describe('When async isolate is completed', () => { + it('Should call the callback', async () => { + const cb = jest.fn(); + + const suite = vest.create(() => { + vest.test('test', () => false); + + vest.group('group', async () => { + await wait(1000); + }); + }); + + suite().done(cb); + await wait(1000); + expect(cb).toHaveBeenCalled(); + }); + }); + }); });