2016-04-24 22:41:37 +02:00
|
|
|
'use strict';
|
2016-10-26 10:43:11 +02:00
|
|
|
|
2016-06-18 21:53:18 +02:00
|
|
|
const assert = require('assert');
|
2016-11-10 21:15:16 +01:00
|
|
|
const specHelper = require('./util/test-helper');
|
2016-06-18 21:53:18 +02:00
|
|
|
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-11-10 21:15:16 +01:00
|
|
|
let request;
|
|
|
|
|
2016-06-18 21:53:18 +02:00
|
|
|
describe('The archive features api', () => {
|
|
|
|
beforeEach(done => {
|
2016-11-10 21:15:16 +01:00
|
|
|
specHelper.setupApp().then((app) => {
|
|
|
|
request = app.request;
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-12-17 21:56:27 +01:00
|
|
|
|
2016-06-18 21:53:18 +02:00
|
|
|
it('returns three archived toggles', done => {
|
2014-12-17 21:56:27 +01:00
|
|
|
request
|
2016-11-09 22:31:49 +01:00
|
|
|
.get('/api/archive/features')
|
2014-12-17 21:56:27 +01:00
|
|
|
.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
|
2016-11-09 22:31:49 +01:00
|
|
|
.post('/api/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
|
2016-11-09 22:31:49 +01:00
|
|
|
.post('/api/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
|
|
|
});
|