"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.CallOrderChecker = CallOrderChecker;
/**
 * Creates a spy and stores its reference for later call order checking
 * @param {function} spy
 * @constructor
 */
function CallOrderChecker(spy) {
  var order = [];
  this.fn = function () {
    var fn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
    var wrapper = spy(function () {
      order.push(wrapper);
      return fn.apply(void 0, arguments);
    });
    return wrapper;
  };
  this.precedes = function (fn1, fn2) {
    var fn1idx = order.indexOf(fn1);
    return fn1idx !== -1 && fn1idx < order.indexOf(fn2);
  };
}