-
Notifications
You must be signed in to change notification settings - Fork 542
/
init.test.ts
30 lines (28 loc) · 1.03 KB
/
init.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import * as buildHandlerModule from '../build/buildHandler';
import * as initHandlerModule from './initHandler';
import initModule from '.';
describe('init module', () => {
it('console logs if successful', async () => {
const chdirMock = jest.spyOn(process, 'chdir').mockImplementation(() => {
/* noop */
});
const mockArgv = { directory: 'foo', snapLocation: 'foo' };
const initHandlerMock = jest
.spyOn(initHandlerModule, 'initHandler')
.mockImplementation(() => ({ ...(mockArgv as any) }));
const buildMock = jest
.spyOn(buildHandlerModule, 'build')
.mockImplementation();
jest.spyOn(console, 'log').mockImplementation();
await initModule.handler({ ...(mockArgv as any) });
expect(initHandlerMock).toHaveBeenCalledWith(mockArgv);
expect(chdirMock).toHaveBeenCalledTimes(1);
expect(buildMock).toHaveBeenCalledWith({
directory: 'foo',
snapLocation: 'foo',
manifest: false,
eval: true,
});
expect(global.console.log).toHaveBeenCalledTimes(1);
});
});