UNPKG

@mbc-cqrs-serverless/cli

Version:

a CLI to get started with MBC CQRS serverless framework

37 lines (36 loc) 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = require("child_process"); const new_action_1 = require("./new.action"); const { isLatestCli } = new_action_1.exportsForTesting; jest.mock('child_process', () => ({ execSync: jest.fn(), })); jest.mock('fs', () => ({ readFileSync: jest.fn(() => JSON.stringify({ version: '1.0.0' })), })); jest.mock('path', () => ({ join: jest.fn(() => '/mocked/path/to/package.json'), })); describe('isLatestCli', () => { const mockExecSync = child_process_1.execSync; afterEach(() => { jest.clearAllMocks(); }); it('should return true if the current version matches the latest version', () => { const mockLatestVersion = ['1.0.0']; mockExecSync.mockReturnValue(Buffer.from(`${mockLatestVersion}\n`)); // Run the function const result = isLatestCli(); // Assert that the result is true expect(result).toBe(true); }); it('should return false if the current version does not match the latest version', () => { const mockLatestVersion = ['1.2.3']; mockExecSync.mockReturnValue(Buffer.from(`${mockLatestVersion}\n`)); // Run the function const result = isLatestCli(); // Assert that the result is true expect(result).toBe(false); }); });