UNPKG

@applicaster/zapplicaster-cli

Version:

CLI Tool for the zapp app and Quick Brick project

86 lines (69 loc) 2.4 kB
const appVersionId = "e7a17c6f-4113-41ac-9450-6281d22153a1"; const options = { appVersionId, pluginPath: "/plugins/my-plugin", }; const mock_config = { ...options, }; jest.mock("../../prepareWorkspace/prerequisitesChecker.js", () => ({ prerequisitesChecker: jest.fn(() => true), })); jest.mock("../configurator.js", () => ({ configurator: jest.fn(() => mock_config), })); jest.mock("../npmPublish.js", () => ({ npmPublish: jest.fn(() => true), })); jest.mock("../generateManifest.js", () => ({ generateManifest: jest.fn(() => true), })); jest.mock("../zappifestPublish.js", () => ({ zappifestPublish: jest.fn(() => true), })); jest.mock("../commitToGit.js", () => ({ commitToGit: jest.fn(() => true), })); jest.mock("../../../logger", () => ({ welcome: jest.fn(), log: jest.fn(), error: jest.fn(), warn: jest.fn(), startStep: jest.fn(), endStep: jest.fn(), success: jest.fn(), })); const { prerequisitesChecker, } = require("../../prepareWorkspace/prerequisitesChecker.js"); const { configurator } = require("../configurator"); const { npmPublish } = require("../npmPublish"); const { generateManifest } = require("../generateManifest"); const { zappifestPublish } = require("../zappifestPublish"); const { commitToGit } = require("../commitToGit"); const logger = require("../../../logger"); const { publishPlugin } = require("../index"); describe("publish plugin command", () => { it("runs the task", async () => { await publishPlugin(appVersionId, options); expect(logger.welcome.mock.calls).toMatchSnapshot(); expect(logger.log.mock.calls).toMatchSnapshot(); expect(logger.error.mock.calls).toMatchSnapshot(); expect(logger.warn.mock.calls).toMatchSnapshot(); expect(logger.startStep.mock.calls).toMatchSnapshot(); expect(logger.endStep.mock.calls).toMatchSnapshot(); expect(logger.success.mock.calls).toMatchSnapshot(); expect(prerequisitesChecker).toHaveBeenCalledWith({ cliArgs: [appVersionId], cliOptions: options, }); expect(configurator).toHaveBeenCalledWith({ cliArgs: [appVersionId], cliOptions: options, }); expect(npmPublish).toHaveBeenCalledWith(mock_config); expect(generateManifest).toHaveBeenCalledWith(mock_config); expect(zappifestPublish).toHaveBeenCalledWith(mock_config); expect(commitToGit).toHaveBeenCalledWith(mock_config); }); });