2016-04-24 22:41:37 +02:00
|
|
|
'use strict';
|
2016-06-18 21:53:18 +02:00
|
|
|
const assert = require('assert');
|
|
|
|
const specHelper = require('./specHelper');
|
|
|
|
const request = specHelper.request;
|
|
|
|
const stringify = function (o) {
|
2016-04-24 22:41:37 +02:00
|
|
|
return JSON.stringify(o, null, ' ');
|
|
|
|
};
|
2014-12-17 21:56:27 +01:00
|
|
|
|
2016-06-18 21:53:18 +02:00
|
|
|
describe('The archive features api', () => {
|
|
|
|
beforeEach(done => {
|
2014-12-17 21:56:27 +01:00
|
|
|
specHelper.db.resetAndSetup()
|
|
|
|
.then(done.bind(null, null))
|
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
|
2016-06-18 21:53:18 +02:00
|
|
|
it('returns three archived toggles', done => {
|
2014-12-17 21:56:27 +01:00
|
|
|
request
|
|
|
|
.get('/archive/features')
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect(200)
|
2016-06-18 21:53:18 +02:00
|
|
|
.end((err, res) => {
|
|
|
|
assert(res.body.features.length === 3, `expected 3 features, got ${stringify(res.body)}`);
|
2014-12-17 21:56:27 +01:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-06-18 21:53:18 +02:00
|
|
|
it('revives a feature by name', done => {
|
2014-12-17 21:56:27 +01:00
|
|
|
request
|
|
|
|
.post('/archive/revive')
|
2016-04-24 22:41:37 +02:00
|
|
|
.send({ name: 'featureArchivedX' })
|
2014-12-17 21:56:27 +01:00
|
|
|
.set('Content-Type', 'application/json')
|
|
|
|
.expect(200, done);
|
|
|
|
});
|
|
|
|
|
2016-06-18 21:53:18 +02:00
|
|
|
it('must set name when reviving toggle', done => {
|
2014-12-17 21:56:27 +01:00
|
|
|
request
|
|
|
|
.post('/archive/revive')
|
2016-09-10 10:11:18 +02:00
|
|
|
.send({ name: '' })
|
2014-12-17 21:56:27 +01:00
|
|
|
.expect(400, done);
|
|
|
|
});
|
2016-04-24 22:41:37 +02:00
|
|
|
});
|