1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/packages/unleash-api/test/e2e/featureArchiveApiSpec.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

'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) {
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')
.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);
});
});