navy
Version:
Quick and powerful development environments using Docker and Docker Compose
120 lines (118 loc) • 3.12 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _chai = require("chai");
var _develop = _interopRequireDefault(require("../develop"));
/* eslint-env mocha */
describe('develop middleware', function () {
it('should return the service unchanged when no service state exists', function () {
const config = {
services: {
api: {
image: 'api',
command: 'npm start'
}
}
};
const state = {
services: {}
};
const result = (0, _develop.default)(config, state);
(0, _chai.expect)(result.services.api).to.eql({
image: 'api',
command: 'npm start'
});
});
it('should return the service unchanged when state has no _develop entry', function () {
const config = {
services: {
api: {
image: 'api',
command: 'npm start'
}
}
};
const state = {
services: {
api: {
unrelated: true
}
}
};
const result = (0, _develop.default)(config, state);
(0, _chai.expect)(result.services.api).to.eql({
image: 'api',
command: 'npm start'
});
});
it('should set stdin_open and append _develop.mounts as volumes', function () {
const config = {
services: {
api: {
image: 'api',
volumes: ['./preexisting:/preexisting'],
command: 'npm start'
}
}
};
const state = {
services: {
api: {
_develop: {
mounts: {
'./local': '/app',
'./node_modules': '/app/node_modules'
}
}
}
}
};
const result = (0, _develop.default)(config, state);
(0, _chai.expect)(result.services.api.stdin_open).to.equal(true);
(0, _chai.expect)(result.services.api.volumes).to.include('./preexisting:/preexisting');
(0, _chai.expect)(result.services.api.volumes).to.include('./local:/app');
(0, _chai.expect)(result.services.api.volumes).to.include('./node_modules:/app/node_modules');
});
it('should override the command when _develop.command is set', function () {
const config = {
services: {
api: {
image: 'api',
command: 'npm start'
}
}
};
const state = {
services: {
api: {
_develop: {
mounts: {},
command: 'npm run dev'
}
}
}
};
const result = (0, _develop.default)(config, state);
(0, _chai.expect)(result.services.api.command).to.equal('npm run dev');
});
it('should keep the existing command when _develop.command is not set', function () {
const config = {
services: {
api: {
image: 'api',
command: 'npm start'
}
}
};
const state = {
services: {
api: {
_develop: {
mounts: {}
}
}
}
};
const result = (0, _develop.default)(config, state);
(0, _chai.expect)(result.services.api.command).to.equal('npm start');
});
});