wix-style-react
Version:
wix-style-react
23 lines (19 loc) • 1.02 kB
JavaScript
import wixEventually from 'wix-eventually';
var DEFAULT_INTERVAL_MS = 10; // Reasonable interval for a component library which doesn't do any fetching
export var eventually = function eventually(fn) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_timeout = _ref.timeout,
_interval = _ref.interval;
var testFrameworkTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
var interval = _interval || DEFAULT_INTERVAL_MS;
var suggestedTimeout = testFrameworkTimeout && testFrameworkTimeout - 2 * interval;
var timeout = void 0;
if (_timeout) {
if (suggestedTimeout && _timeout > suggestedTimeout) {
throw new Error('eventually: options.timeout of ' + _timeout + ' should be smaller than the suggested timeout (testFrameworkTimeout - 2 * interval = ' + testFrameworkTimeout + ' - 2 * ' + interval + ' = ' + suggestedTimeout + ')');
}
} else {
timeout = suggestedTimeout;
}
return wixEventually(fn, { timeout: timeout, interval: interval });
};