wix-style-react
Version:
wix-style-react
30 lines (28 loc) • 1.23 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.eventually = void 0;
var _wixEventually = _interopRequireDefault(require("wix-eventually"));
var DEFAULT_INTERVAL_MS = 10; // Reasonable interval for a component library which does not do any fetching
var eventually = exports.eventually = function eventually(fn) {
var {
timeout: _timeout,
interval: _interval
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var testFrameworkTimeout = 10000;
var interval = _interval || DEFAULT_INTERVAL_MS;
var suggestedTimeout = testFrameworkTimeout && testFrameworkTimeout - 2 * interval;
var timeout;
if (_timeout) {
if (suggestedTimeout && _timeout > suggestedTimeout) {
throw new Error("eventually: options.timeout of ".concat(_timeout, " should be smaller than the suggested timeout (testFrameworkTimeout - 2 * interval = ").concat(testFrameworkTimeout, " - 2 * ").concat(interval, " = ").concat(suggestedTimeout, ")"));
}
} else {
timeout = suggestedTimeout;
}
return (0, _wixEventually.default)(fn, {
timeout,
interval
});
};
//# sourceMappingURL=eventually.js.map