1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00

should expose one feature

This commit is contained in:
sveisvei 2017-06-28 12:52:27 +02:00
parent fad5700d0f
commit 447940ed0c
2 changed files with 26 additions and 0 deletions

View File

@ -14,5 +14,14 @@ exports.router = config => {
.then(features => res.json({ version, features }));
});
router.get('/:featureName', (req, res) => {
featureToggleStore
.getFeature(req.params.featureName)
.then(feature => res.json(feature).end())
.catch(() =>
res.status(404).json({ error: 'Could not find feature' })
);
});
return router;
};

View File

@ -40,3 +40,20 @@ test('should get empty getFeatures via client', t => {
t.true(res.body.features.length === 0);
});
});
test('fetch single feature', t => {
t.plan(1);
const { request, featureToggleStore, base } = getSetup();
featureToggleStore.addFeature({
name: 'test_',
strategies: [{ name: 'default' }],
});
return request
.get(`${base}/api/client/features/test_`)
.expect('Content-Type', /json/)
.expect(200)
.expect(res => {
t.true(res.body.name === 'test_');
});
});