2014-11-25 14:41:11 +01:00
|
|
|
var specHelper = require('./specHelper');
|
2014-10-20 15:12:30 +02:00
|
|
|
|
2014-11-25 14:41:11 +01:00
|
|
|
describe('The features api', function () {
|
|
|
|
var request;
|
2014-10-20 15:12:30 +02:00
|
|
|
|
2014-11-25 14:41:11 +01:00
|
|
|
before(function () { request = specHelper.setupMockServer(); });
|
|
|
|
after(specHelper.tearDownMockServer);
|
2014-10-20 15:12:30 +02:00
|
|
|
|
|
|
|
it('returns three mocked feature toggles', function (done) {
|
|
|
|
request
|
|
|
|
.get('/features')
|
2014-10-24 16:15:59 +02:00
|
|
|
.expect('Content-Type', /json/)
|
2014-10-20 15:12:30 +02:00
|
|
|
.expect(200, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('creates new feature toggle', function (done) {
|
|
|
|
request
|
|
|
|
.post('/features')
|
2014-10-22 15:52:43 +02:00
|
|
|
.send({name: 'com.test.feature', 'enabled': false})
|
2014-10-20 15:12:30 +02:00
|
|
|
.set('Content-Type', 'application/json')
|
|
|
|
.expect(201, done);
|
|
|
|
});
|
2014-10-21 16:02:23 +02:00
|
|
|
|
2014-11-01 11:47:21 +01:00
|
|
|
it('require new feature toggle to have a name', function (done) {
|
|
|
|
request
|
|
|
|
.post('/features')
|
|
|
|
.send({name: ''})
|
|
|
|
.set('Content-Type', 'application/json')
|
|
|
|
.expect(400, done);
|
|
|
|
});
|
|
|
|
|
2014-11-10 17:10:39 +01:00
|
|
|
it('can not change status of feature toggle that does not exist', function (done) {
|
2014-10-21 16:02:23 +02:00
|
|
|
request
|
2014-11-14 12:56:23 +01:00
|
|
|
.put('/features/should-not-exist')
|
|
|
|
.send({name: 'should-not-exist', enabled: false})
|
2014-10-21 16:02:23 +02:00
|
|
|
.set('Content-Type', 'application/json')
|
2014-10-22 15:52:43 +02:00
|
|
|
.expect(404, done);
|
|
|
|
});
|
|
|
|
|
2014-11-10 17:10:39 +01:00
|
|
|
it('can change status of feature toggle that does exist', function (done) {
|
2014-10-22 15:52:43 +02:00
|
|
|
request
|
2014-11-14 12:56:23 +01:00
|
|
|
.put('/features/featureY')
|
|
|
|
.send({name: 'featureY', enabled: true})
|
2014-10-22 15:52:43 +02:00
|
|
|
.set('Content-Type', 'application/json')
|
2014-11-14 12:56:23 +01:00
|
|
|
.expect(200, done);
|
2014-10-21 16:02:23 +02:00
|
|
|
});
|
|
|
|
|
2014-10-20 15:12:30 +02:00
|
|
|
});
|