create-nttb
Version:
An opinionated Next.js, TypeScript, and Tailwind boilerplate using Atomic Design Methodology for presentation components.
49 lines • 1.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
jest.mock("./install", () => ({
main: jest.fn(),
}));
jest.mock("./update", () => ({
main: jest.fn(),
}));
const index_1 = require("./index");
const install_1 = require("./install");
const update_1 = require("./update");
describe("create-nttb CLI routing", () => {
const originalArgv = process.argv;
let consoleErrorSpy;
beforeEach(() => {
process.argv = [...originalArgv];
consoleErrorSpy = jest.spyOn(console, "error").mockImplementation(() => { });
jest.clearAllMocks();
});
afterEach(() => {
process.argv = [...originalArgv];
consoleErrorSpy.mockRestore();
});
test("calls install command", async () => {
process.argv = ["node", "index.js", "install"];
await (0, index_1.main)();
expect(install_1.main).toHaveBeenCalledWith();
expect(update_1.main).not.toHaveBeenCalled();
});
test("calls update command", async () => {
process.argv = ["node", "index.js", "update"];
await (0, index_1.main)();
expect(update_1.main).toHaveBeenCalledWith(undefined);
expect(install_1.main).not.toHaveBeenCalled();
});
test("calls update command with target path", async () => {
process.argv = ["node", "index.js", "update", "../my-app"];
await (0, index_1.main)();
expect(update_1.main).toHaveBeenCalledWith("../my-app");
expect(install_1.main).not.toHaveBeenCalled();
});
test("treats other arg as project name", async () => {
process.argv = ["node", "index.js", "my-app"];
await (0, index_1.main)();
expect(install_1.main).toHaveBeenCalledWith("my-app");
expect(update_1.main).not.toHaveBeenCalled();
});
});
//# sourceMappingURL=index.test.js.map