navy
Version:
Quick and powerful development environments using Docker and Docker Compose
53 lines (51 loc) • 1.97 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _chai = require("chai");
var _sinon = _interopRequireDefault(require("sinon"));
var _proxyquire = _interopRequireDefault(require("proxyquire"));
/* eslint-env mocha */
describe('cli/config/wrapper', function () {
let sandbox;
let execSyncStub;
let originalArgv;
let wrapperCli;
beforeEach(function () {
sandbox = _sinon.default.createSandbox();
execSyncStub = sandbox.stub();
originalArgv = process.argv;
wrapperCli = _proxyquire.default.noCallThru()('../wrapper', {
child_process: {
execSync: execSyncStub
}
});
});
afterEach(function () {
process.argv = originalArgv;
sandbox.restore();
});
describe('default export', function () {
it('should invoke navy-config.js via execSync with stdio inherit', async function () {
process.argv = ['node', 'navy', 'config'];
await wrapperCli('env-1');
(0, _chai.expect)(execSyncStub.calledOnce).to.equal(true);
const command = execSyncStub.firstCall.args[0];
(0, _chai.expect)(command).to.contain('navy-config.js');
const opts = execSyncStub.firstCall.args[1];
(0, _chai.expect)(opts).to.eql({
stdio: 'inherit'
});
});
it('should pass through any extra command-line args from process.argv', async function () {
process.argv = ['node', 'navy', 'config', 'set', 'default-navy', 'dev'];
await wrapperCli('env-1');
const command = execSyncStub.firstCall.args[0];
(0, _chai.expect)(command).to.contain('set default-navy dev');
});
it('should invoke with no extra args when only the wrapper command is supplied', async function () {
process.argv = ['node', 'navy', 'config'];
await wrapperCli('env-1');
const command = execSyncStub.firstCall.args[0];
(0, _chai.expect)(command.endsWith('navy-config.js ')).to.equal(true);
});
});
});