wix-style-react
Version:
wix-style-react
29 lines (28 loc) • 1.28 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.runAbsolutelyAllTimers = void 0;
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _react = require("../react");
// This is needed because animation libraries have complex internal behaviour involving timers.
// This allows us to resolve all the timers, before our test expectations
var runAbsolutelyAllTimers = exports.runAbsolutelyAllTimers = /*#__PURE__*/function () {
var _ref = (0, _asyncToGenerator2.default)(function* () {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
limit: 10
};
var i = 0;
for (i; jest.getTimerCount() && i < params.limit; i++) {
yield (0, _react.act)(/*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
jest.runAllTimers();
}));
}
if (i >= params.limit) {
throw Error('Exceeded custom runAllTimers() call limit. Most likely you have recursive timers, try using jest.runOnlyPendingTimers() instead.');
}
});
return function runAbsolutelyAllTimers() {
return _ref.apply(this, arguments);
};
}();
//# sourceMappingURL=runAbsolutelyAllTimers.js.map