1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/test/fixtures/fake-feature-toggle-store.js

32 lines
1.0 KiB
JavaScript
Raw Normal View History

2016-11-05 17:02:46 +01:00
'use strict';
module.exports = () => {
2016-11-13 15:41:35 +01:00
const _features = [];
2017-12-18 14:31:59 +01:00
const _archive = [];
2016-11-13 15:41:35 +01:00
return {
getFeature: name => {
const toggle = _features.find(f => f.name === name);
if (toggle) {
return Promise.resolve(toggle);
} else {
return Promise.reject();
}
},
hasFeature: name => {
const toggle = _features.find(f => f.name === name);
const archived = _archive.find(f => f.name === name);
if (toggle) {
return Promise.resolve({ name, archived: false });
} else if (archived) {
return Promise.resolve({ name, archived: true });
} else {
return Promise.reject();
}
},
2016-11-13 15:41:35 +01:00
getFeatures: () => Promise.resolve(_features),
addFeature: feature => _features.push(feature),
2017-12-18 14:31:59 +01:00
getArchivedFeatures: () => Promise.resolve(_archive),
addArchivedFeature: feature => _archive.push(feature),
2016-11-13 15:41:35 +01:00
};
2016-11-05 17:02:46 +01:00
};