mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
const test = require('ava');
|
|
const { setupApp } = require('../../helpers/test-helper');
|
|
const dbInit = require('../../helpers/database-init');
|
|
const getLogger = require('../../../fixtures/no-logger');
|
|
|
|
let stores;
|
|
|
|
test.before(async () => {
|
|
const db = await dbInit('feature_api_client', getLogger);
|
|
stores = db.stores;
|
|
});
|
|
|
|
test.after(async () => {
|
|
await stores.db.destroy();
|
|
});
|
|
|
|
test.serial('returns four feature toggles', async t => {
|
|
const request = await setupApp(stores);
|
|
return request
|
|
.get('/api/client/features')
|
|
.expect('Content-Type', /json/)
|
|
.expect(200)
|
|
.expect(res => {
|
|
t.is(res.body.features.length, 4);
|
|
});
|
|
});
|
|
|
|
test.serial('returns four feature toggles without createdAt', async t => {
|
|
const request = await setupApp(stores);
|
|
return request
|
|
.get('/api/client/features')
|
|
.expect('Content-Type', /json/)
|
|
.expect(200)
|
|
.expect(res => {
|
|
t.falsy(res.body.features[0].createdAt);
|
|
});
|
|
});
|
|
|
|
test.serial('gets a feature by name', async t => {
|
|
t.plan(0);
|
|
const request = await setupApp(stores);
|
|
return request
|
|
.get('/api/client/features/featureX')
|
|
.expect('Content-Type', /json/)
|
|
.expect(200);
|
|
});
|
|
|
|
test.serial('cant get feature that dose not exist', async t => {
|
|
t.plan(0);
|
|
const request = await setupApp(stores);
|
|
return request
|
|
.get('/api/client/features/myfeature')
|
|
.expect('Content-Type', /json/)
|
|
.expect(404);
|
|
});
|