@paralleldrive/react-feature-toggles
Version:
React Feature Toggles
90 lines (71 loc) • 3.23 kB
JavaScript
;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _riteway = require('riteway');
var _curry = require('./curry');
var _curry2 = _interopRequireDefault(_curry);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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"); }); }; }
var addTwo = function addTwo(a, b) {
return a + b;
};
var addThree = function addThree(a, b, c) {
return a + b + c;
};
(0, _riteway.describe)('curry()', function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(assert) {
var given, curriedAddTwo, _given, curriedAddThree;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
given = 'a function with 2 arguments';
curriedAddTwo = (0, _curry2.default)(addTwo);
assert({
given: given,
should: 'return a new function',
actual: typeof curriedAddTwo === 'undefined' ? 'undefined' : _typeof(curriedAddTwo),
expected: 'function'
});
assert({
given: given,
should: 'return a function that can be used in curried format',
actual: curriedAddTwo(3)(5),
expected: 8
});
assert({
given: given,
should: 'return a function that can be used in uncurried format',
actual: curriedAddTwo(3, 5),
expected: 8
});
_given = 'a function with 3 arguments';
curriedAddThree = (0, _curry2.default)(addThree);
assert({
given: _given,
should: 'return a new function',
actual: typeof curriedAddThree === 'undefined' ? 'undefined' : _typeof(curriedAddThree),
expected: 'function'
});
assert({
given: _given,
should: 'return a function that can be used in curried format',
actual: curriedAddThree(3)(5)(2),
expected: 10
});
assert({
given: _given,
should: 'return a function that can be used in uncurried format',
actual: curriedAddThree(3, 5, 2),
expected: 10
});
case 10:
case 'end':
return _context.stop();
}
}
}, _callee, undefined);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}());