UNPKG

@helpscout/cyan

Version:

Cypress-like Testing for React + JSDOM

30 lines (23 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.combineCommands = exports.withCommands = void 0; function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var withCommands = function (commandList) { return function (baseClass) { var commands = Object.keys(commandList); commands.forEach(function (key) { baseClass.prototype[key] = commandList[key]; }); return baseClass; }; }; exports.withCommands = withCommands; var combineCommands = function (commandList) { return Object.keys(commandList).reduce(function (commands, key) { return _objectSpread({}, commands, commandList[key]); }, {}); }; exports.combineCommands = combineCommands;