From a805a52c274e6c4217117ee6f003403487dcc0b7 Mon Sep 17 00:00:00 2001 From: Mikhail Nasyrov Date: Sun, 25 Jul 2021 09:37:30 +0700 Subject: [PATCH] test: Increased the coverage --- packages/rx-effects/src/effect.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/rx-effects/src/effect.test.ts b/packages/rx-effects/src/effect.test.ts index 423a278..b6f8cbf 100644 --- a/packages/rx-effects/src/effect.test.ts +++ b/packages/rx-effects/src/effect.test.ts @@ -149,6 +149,29 @@ describe('Effect', () => { expect(await final).toBe(1); }); + it('should handle completion of the observable', async () => { + const effect = createEffect((value: number) => value * 2); + + const onSourceCompleted = jest.fn(); + effect.handle(of(1), { + onSourceCompleted, + }); + + expect(onSourceCompleted).toBeCalledTimes(1); + }); + + it('should handle an error of the observable', async () => { + const effect = createEffect((value: number) => value * 2); + + const onSourceFailed = jest.fn(); + effect.handle(throwError(new Error('test error')), { + onSourceFailed, + }); + + expect(onSourceFailed).toBeCalledTimes(1); + expect(onSourceFailed).toBeCalledWith(new Error('test error')); + }); + it('should handle error from the source', async () => { const effect = createEffect((value: number) => value * 2);