Skip to content

Commit

Permalink
Testing Mock Process
Browse files Browse the repository at this point in the history
Signed-off-by: vr-varad <[email protected]>
  • Loading branch information
vr-varad committed Nov 16, 2024
1 parent 69d7f7d commit c97c970
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/testing/__test__/process.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});

0 comments on commit c97c970

Please sign in to comment.