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:
parent
fad5700d0f
commit
447940ed0c
@ -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;
|
||||
};
|
||||
|
@ -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_');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user