-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.test.ts
26 lines (22 loc) · 946 Bytes
/
common.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
import * as fs from "fs";
import { runClasp } from '../src/common';
jest.mock('../src/utils', () => ({
__esModule: true, // this property makes it work
execShellCommand: jest.fn().mockResolvedValue({error: null, stdout: "", stderr: ""}),
}));
jest.mock("fs", () => ({
writeFile: jest.fn().mockResolvedValue(true),
}));
describe('common.js tests', () => {
describe('runClasp push', () => {
test('with wrong inputs', async () => {
expect(await runClasp({scriptId:null, rootDir:null}, "push", "")).toBeFalsy();
expect(await runClasp({scriptId:"", rootDir:null}, "push", "")).toBeFalsy();
expect(await runClasp(undefined, undefined, undefined)).toBeFalsy();
});
test('valid inputs', async () => {
expect(await runClasp({scriptId:"123", rootDir:"src"}, "push", "")).toBeTruthy();
expect(fs.writeFile).toHaveBeenCalledTimes(1);
});
});
});