"use strict";

exports.__esModule = true;
exports.eventually = void 0;
var _awaiterUtils = require("@wix/awaiter-utils");
var DEFAULT_INTERVAL_MS = 10; // Reasonable interval for a component library which does not do any fetching

var eventually = (fn, params) => {
  var testFrameworkTimeout = 10000;
  var interval = (params == null ? void 0 : params.interval) || DEFAULT_INTERVAL_MS;
  var suggestedTimeout = testFrameworkTimeout && testFrameworkTimeout - 2 * interval;
  var timeout;
  if (params != null && params.timeout) {
    if (suggestedTimeout && (params == null ? void 0 : params.timeout) > suggestedTimeout) {
      throw new Error("eventually: options.timeout of ".concat(params == null ? void 0 : params.timeout, " should be smaller than the suggested timeout (testFrameworkTimeout - 2 * interval = ").concat(testFrameworkTimeout, " - 2 * ").concat(interval, " = ").concat(suggestedTimeout, ")"));
    }
  } else {
    timeout = suggestedTimeout;
  }
  return (0, _awaiterUtils.eventually)(fn, {
    timeout,
    interval
  });
};
exports.eventually = eventually;
//# sourceMappingURL=eventually.js.map