UNPKG

multi-clasp2

Version:

Google Clasp wrapper to push changes to multiple Apps Script projects at once.

28 lines (27 loc) 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const multiClaspMocks_1 = require("./_mocks/multiClaspMocks"); const fs = tslib_1.__importStar(require("fs")); const common_1 = require("../src/common"); const writeFileMock = fs.writeFile; describe("common.js tests", () => { beforeEach(() => { multiClaspMocks_1.execMock.mockReset(); multiClaspMocks_1.execMock.mockResolvedValue({ error: null, stdout: "", stderr: "" }); writeFileMock.mockClear(); }); describe("runClasp push", () => { test("with wrong inputs", async () => { expect(await (0, common_1.runClasp)({ scriptId: null, rootDir: null }, "push", "")).toBeFalsy(); expect(await (0, common_1.runClasp)({ scriptId: "", rootDir: null }, "push", "")).toBeFalsy(); expect(await (0, common_1.runClasp)(undefined, undefined, undefined)).toBeFalsy(); }); test("valid inputs", async () => { expect(await (0, common_1.runClasp)({ scriptId: "123", rootDir: "src" }, "push", "")).toBeTruthy(); expect(writeFileMock).toHaveBeenCalledTimes(1); expect(multiClaspMocks_1.execMock).toHaveBeenCalledTimes(1); expect(multiClaspMocks_1.execMock.mock.calls[0][0]).toBe("npx clasp push "); }); }); });