navy
Version:
Quick and powerful development environments using Docker and Docker Compose
65 lines (63 loc) • 2.21 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/open', function () {
let sandbox;
let getNavyStub;
let navyStub;
let openStub;
let consoleLogStub;
let openCli;
beforeEach(function () {
sandbox = _sinon.default.createSandbox();
navyStub = {
url: sandbox.stub().resolves('http://service.local')
};
getNavyStub = sandbox.stub().returns(navyStub);
openStub = sandbox.stub();
consoleLogStub = sandbox.stub(console, 'log');
openCli = _proxyquire.default.noCallThru()('../open', {
open: openStub,
'../': {
getNavy: getNavyStub
}
});
});
afterEach(function () {
sandbox.restore();
});
describe('default export', function () {
it('should resolve the navy instance using opts.navy', async function () {
await openCli('api', {
navy: 'env-1'
});
(0, _chai.expect)(getNavyStub.calledOnce).to.equal(true);
(0, _chai.expect)(getNavyStub.firstCall.args[0]).to.equal('env-1');
});
it('should resolve the URL for the requested service via navy.url', async function () {
await openCli('api', {
navy: 'env-1'
});
(0, _chai.expect)(navyStub.url.calledOnce).to.equal(true);
(0, _chai.expect)(navyStub.url.firstCall.args[0]).to.equal('api');
});
it('should pass the resolved URL to the open package', async function () {
navyStub.url.resolves('http://my-service.test');
await openCli('api', {
navy: 'env-1'
});
(0, _chai.expect)(openStub.calledOnce).to.equal(true);
(0, _chai.expect)(openStub.firstCall.args[0]).to.equal('http://my-service.test');
});
it('should log a message indicating which service is being opened', async function () {
await openCli('api', {
navy: 'env-1'
});
(0, _chai.expect)(consoleLogStub.calledOnce).to.equal(true);
(0, _chai.expect)(consoleLogStub.firstCall.args[0]).to.contain('Opening api...');
});
});
});