mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-01 00:08:27 +01:00
Merge pull request #238 from Unleash/add-client-feature-endpoint
should expose one feature
This commit is contained in:
commit
0640879f00
@ -14,5 +14,14 @@ exports.router = config => {
|
|||||||
.then(features => res.json({ version, features }));
|
.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;
|
return router;
|
||||||
};
|
};
|
||||||
|
@ -40,3 +40,20 @@ test('should get empty getFeatures via client', t => {
|
|||||||
t.true(res.body.features.length === 0);
|
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