@buggyorg/library-specification
Version:
Specification for buggy component library servers.
61 lines (48 loc) • 1.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (serve) {
_chai2.default.use(_chaiHttp2.default);
_chai2.default.use(_chaiAsPromised2.default);
var expect = _chai2.default.expect;
describe('Configuration', function () {
it('get configuration settings', function () {
return serve({ config: { c: 2 } }).then(function (app) {
return _chai2.default.request(app).get('/config/c');
}).then(function (res) {
expect(res.status).to.equal(200);
expect(res.body).to.equal(2);
});
});
it('sets configuration settings', function () {
return serve({ config: {} }).then(function (app) {
return _chai2.default.request(app).post('/config/d').send({ value: 4 }).then(function (res) {
expect(res.status).to.equal(204);
}).then(function () {
return _chai2.default.request(app).get('/config/d');
}).then(function (res) {
expect(res.status).to.equal(200);
expect(res.body).to.equal(4);
});
});
});
it('errors if the post value is invalid', function () {
return serve({ config: {} }).then(function (app) {
return expect(_chai2.default.request(app).post('/config/d').send({ X: 4 }).then(function (res) {})).to.be.rejected;
});
});
it('errors if the config is not defined', function () {
return serve({ config: {} }).then(function (app) {
return expect(_chai2.default.request(app).get('/config/r').then(function (res) {})).to.be.rejected;
});
});
});
};
var _chai = require('chai');
var _chai2 = _interopRequireDefault(_chai);
var _chaiHttp = require('chai-http');
var _chaiHttp2 = _interopRequireDefault(_chaiHttp);
var _chaiAsPromised = require('chai-as-promised');
var _chaiAsPromised2 = _interopRequireDefault(_chaiAsPromised);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }