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

Merge pull request #238 from Unleash/add-client-feature-endpoint

should expose one feature
This commit is contained in:
Sveinung Røsaker 2017-06-28 12:59:04 +02:00 committed by GitHub
commit 0640879f00
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_');
});
});