2014-10-20 15:12:30 +02:00
|
|
|
var request = require('supertest');
|
|
|
|
|
|
|
|
request = request('http://localhost:4242');
|
|
|
|
|
|
|
|
describe('The api', function () {
|
|
|
|
var server;
|
|
|
|
|
|
|
|
before(function () {
|
|
|
|
server = require('../server');
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
|
|
|
server.server.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns three mocked feature toggles', function (done) {
|
|
|
|
request
|
|
|
|
.get('/features')
|
|
|
|
.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-10-22 15:52:43 +02:00
|
|
|
it('can not change status of feature toggle that dose not exsist', function (done) {
|
2014-10-21 16:02:23 +02:00
|
|
|
request
|
2014-10-22 15:52:43 +02:00
|
|
|
.patch('/features/shouldNotExsist')
|
2014-10-21 16:02:23 +02:00
|
|
|
.send({
|
2014-10-22 15:52:43 +02:00
|
|
|
'field': 'enabled',
|
|
|
|
'value': true
|
2014-10-21 16:02:23 +02:00
|
|
|
})
|
|
|
|
.set('Content-Type', 'application/json')
|
2014-10-22 15:52:43 +02:00
|
|
|
.expect(404, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can change status of feature toggle that dose exsist', function (done) {
|
|
|
|
request
|
|
|
|
.patch('/features/featureY')
|
|
|
|
.send({
|
|
|
|
'field': 'enabled',
|
|
|
|
'value': true
|
|
|
|
})
|
|
|
|
.set('Content-Type', 'application/json')
|
|
|
|
.expect(202, done);
|
2014-10-21 16:02:23 +02:00
|
|
|
});
|
|
|
|
|
2014-10-20 15:12:30 +02:00
|
|
|
});
|