1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/test/fixtures/fake-feature-toggle-store.js
Ivar Conradi Østhus d01c9d2dac
fix: use airbnb lint rules directly (#583)
This drops usage of finn-eslint rules as they are no
longer maintained.
2020-04-14 22:29:11 +02:00

31 lines
1005 B
JavaScript

'use strict';
module.exports = () => {
const _features = [];
const _archive = [];
return {
getFeature: name => {
const toggle = _features.find(f => f.name === name);
if (toggle) {
return Promise.resolve(toggle);
}
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 });
}
if (archived) {
return Promise.resolve({ name, archived: true });
}
return Promise.reject();
},
getFeatures: () => Promise.resolve(_features),
addFeature: feature => _features.push(feature),
getArchivedFeatures: () => Promise.resolve(_archive),
addArchivedFeature: feature => _archive.push(feature),
};
};