@paralleldrive/feature-toggles
Version:
Low-level feature toggle tools for Node and browsers.
59 lines (47 loc) • 2.22 kB
JavaScript
;
var _riteway = require('riteway');
var _isActiveFeatureName = require('./is-active-feature-name');
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
(0, _riteway.describe)('isActiveFeatureName()', function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(should) {
var _should, assert;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_should = should(), assert = _should.assert;
assert({
given: 'no arguments',
should: 'return false',
actual: (0, _isActiveFeatureName.isActiveFeatureName)(),
expected: false
});
assert({
given: 'an empty array and id string',
should: 'return false',
actual: (0, _isActiveFeatureName.isActiveFeatureName)('posts', []),
expected: false
});
assert({
given: 'an array of feature names and existing feature id string',
should: 'return true',
actual: (0, _isActiveFeatureName.isActiveFeatureName)('bar', ['foo', 'bar', 'baz']),
expected: true
});
assert({
given: 'an array of feature names and non existant feature id string',
should: 'return false',
actual: (0, _isActiveFeatureName.isActiveFeatureName)('non-existant-feature-id', ['foo', 'bar', 'baz']),
expected: false
});
case 5:
case 'end':
return _context.stop();
}
}
}, _callee, undefined);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}());