2017-06-28 10:20:22 +02:00
|
|
|
'use strict';
|
|
|
|
|
2018-12-17 09:24:49 +01:00
|
|
|
const test = require('ava');
|
2017-11-16 16:45:01 +01:00
|
|
|
const { setupApp } = require('./../../helpers/test-helper');
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2019-01-24 08:39:21 +01:00
|
|
|
test.serial('returns four feature toggles', async t => {
|
2017-11-16 16:45:01 +01:00
|
|
|
const { request, destroy } = await setupApp('feature_api_client');
|
|
|
|
return request
|
|
|
|
.get('/api/client/features')
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect(200)
|
|
|
|
.expect(res => {
|
2019-01-24 08:39:21 +01:00
|
|
|
t.true(res.body.features.length === 4);
|
2017-11-16 16:45:01 +01:00
|
|
|
})
|
|
|
|
.then(destroy);
|
|
|
|
});
|
|
|
|
|
|
|
|
test.serial('gets a feature by name', async t => {
|
|
|
|
t.plan(0);
|
|
|
|
const { request, destroy } = await setupApp('feature_api_client');
|
|
|
|
return request
|
|
|
|
.get('/api/client/features/featureX')
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect(200)
|
|
|
|
.then(destroy);
|
|
|
|
});
|
|
|
|
|
|
|
|
test.serial('cant get feature that dose not exist', async t => {
|
|
|
|
t.plan(0);
|
|
|
|
const { request, destroy } = await setupApp('feature_api_client');
|
|
|
|
return request
|
|
|
|
.get('/api/client/features/myfeature')
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect(404)
|
|
|
|
.then(destroy);
|
|
|
|
});
|