1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-01 00:08:27 +01:00
unleash.unleash/test/unit/routes/feature.test.js

62 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-08-23 01:29:47 +02:00
'use strict';
2016-11-11 15:46:59 +01:00
const store = require('./mocks/store');
2016-11-05 17:02:46 +01:00
const supertest = require('supertest');
2016-08-23 01:29:47 +02:00
const assert = require('assert');
2016-11-11 15:46:59 +01:00
2016-08-23 01:29:47 +02:00
let request;
2016-11-11 15:46:59 +01:00
let featureToggleStore;
2016-08-23 01:29:47 +02:00
describe('Unit: The features api', () => {
beforeEach(done => {
2016-11-11 15:46:59 +01:00
const stores = store.createStores();
2016-08-23 01:29:47 +02:00
const app = require('../../../app')({
baseUriPath: '',
2016-11-11 15:46:59 +01:00
stores: stores,
2016-08-23 01:29:47 +02:00
});
2016-11-11 15:46:59 +01:00
featureToggleStore = stores.featureToggleStore;
2016-08-23 01:29:47 +02:00
request = supertest(app);
done();
});
it('should get empty getFeatures', (done) => {
request
.get('/features')
.expect('Content-Type', /json/)
.expect(200)
.end((err, res) => {
assert(res.body.features.length === 0);
done();
});
});
it('should get one getFeature', (done) => {
2016-11-05 17:02:46 +01:00
featureToggleStore.addFeature( { name: 'test', strategies: [{ name: 'default' }] } );
2016-08-23 01:29:47 +02:00
request
.get('/features')
.expect('Content-Type', /json/)
.expect(200)
.end((err, res) => {
assert(res.body.features.length === 1);
done();
});
});
it('should add version numbers for /features', (done) => {
2016-11-05 17:02:46 +01:00
featureToggleStore.addFeature( { name: 'test', strategies: [{ name: 'default' }] } );
request
.get('/features')
.expect('Content-Type', /json/)
.expect(200)
.end((err, res) => {
assert.equal(res.body.version, 1);
done();
});
});
2016-08-23 01:29:47 +02:00
});