UNPKG

projex

Version:
30 lines (29 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const utils_1 = require("./utils"); const index_1 = require("./index"); const _shared_1 = require("../../../../shared/index"); jest.mock('@shared'); jest.mock('./utils'); describe('executeComponentProcess', () => { beforeEach(() => { jest.clearAllMocks(); }); it('should throw an error if no command is provided', () => { (0, index_1.vtexRunCommand)(undefined); expect(_shared_1.log.error).toHaveBeenCalledWith('no command to execute'); }); it('should replace @S with spaces and @AND with && if the --scape flag is provided', () => { const command = 'npm run build @S --prod @AND git status'; const expectedCommand = 'npm run build --prod && git status'; process.argv = ['', '', '--scape']; (0, index_1.vtexRunCommand)(command); expect(utils_1.executeCommand).toHaveBeenCalledWith(expectedCommand); }); it('should log the command to execute and a loading message', () => { const command = 'git status'; (0, index_1.vtexRunCommand)(command); expect(_shared_1.log.warn).toHaveBeenCalledWith(`command to execute: ${command}`); expect(_shared_1.log.info).toHaveBeenCalledWith('executing command...'); }); });