From c97c9709891f5a462e38f8c8c8f96cbd1c959aaa Mon Sep 17 00:00:00 2001 From: vr-varad Date: Sun, 17 Nov 2024 01:27:31 +0530 Subject: [PATCH] Testing Mock Process Signed-off-by: vr-varad --- packages/testing/__test__/process.spec.ts | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 packages/testing/__test__/process.spec.ts diff --git a/packages/testing/__test__/process.spec.ts b/packages/testing/__test__/process.spec.ts new file mode 100644 index 0000000..3a2ef5c --- /dev/null +++ b/packages/testing/__test__/process.spec.ts @@ -0,0 +1,25 @@ +import { describe, expect, test, vi } from 'vitest'; +import { yasumu } from '../src'; + +describe('Process', () => { + test('should define an exit method', async () => { + const processExitSpy = vi.spyOn(yasumu.process, 'exit').mockImplementation(() => { + return Promise.resolve(); + }); + + await yasumu.process.exit(0); + + expect(processExitSpy).toHaveBeenCalledTimes(1); + expect(processExitSpy).toHaveBeenCalledWith(0); + + processExitSpy.mockRestore(); + }); + + test('should define a relaunch method', async () => { + const relaunchSpy = vi.spyOn(yasumu.process, 'relaunch'); + + await yasumu.process.relaunch(); + + expect(relaunchSpy).toHaveBeenCalledTimes(1); + }); +});