"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _modifiers = require("./modifiers");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
describe('createModifiers', () => {
  var defaultProps = {
    width: undefined,
    moveBy: undefined,
    minWidth: undefined,
    dynamicWidth: undefined,
    appendTo: undefined,
    shouldAnimate: false,
    flip: true,
    flipModifier: undefined,
    fixed: false,
    placement: 'bottom',
    isTestEnv: false
  };
  it('should match default modifiers', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var modifiers = (0, _modifiers.createModifiers)(_objectSpread({}, defaultProps));
    expect(modifiers).toEqual({
      offset: {
        offset: '0px, 0px'
      },
      computeStyle: {
        gpuAcceleration: true
      },
      flip: {
        enabled: true
      },
      preventOverflow: {
        enabled: true
      },
      hide: {
        enabled: true
      }
    });
  }));
  it('should calculate the offset properly using moveBy for the top placement', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var _modifiers$offset;
    var modifiers = (0, _modifiers.createModifiers)(_objectSpread(_objectSpread({}, defaultProps), {}, {
      moveBy: {
        x: 5,
        y: 10
      },
      placement: 'top'
    }));
    expect(modifiers == null || (_modifiers$offset = modifiers.offset) == null ? void 0 : _modifiers$offset.offset).toEqual('5px, 10px');
  }));
  it('should calculate the offset properly using moveBy for the right placement', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var _modifiers$offset2;
    var modifiers = (0, _modifiers.createModifiers)(_objectSpread(_objectSpread({}, defaultProps), {}, {
      moveBy: {
        x: 5,
        y: 10
      },
      placement: 'right'
    }));
    expect(modifiers == null || (_modifiers$offset2 = modifiers.offset) == null ? void 0 : _modifiers$offset2.offset).toEqual('10px, 5px');
  }));
  it('should disable gpuAcceleration when animation is enabled', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var _modifiers$computeSty;
    var modifiers = (0, _modifiers.createModifiers)(_objectSpread(_objectSpread({}, defaultProps), {}, {
      shouldAnimate: true
    }));
    expect(modifiers == null || (_modifiers$computeSty = modifiers.computeStyle) == null ? void 0 : _modifiers$computeSty.gpuAcceleration).toEqual(false);
  }));
  it('should disable the flip modifier if moveBy was provided', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var _modifiers$flip;
    var modifiers = (0, _modifiers.createModifiers)(_objectSpread(_objectSpread({}, defaultProps), {}, {
      moveBy: {
        x: 5,
        y: 10
      },
      flip: undefined
    }));
    expect(modifiers == null || (_modifiers$flip = modifiers.flip) == null ? void 0 : _modifiers$flip.enabled).toEqual(false);
  }));
  it('should enabled the flip modifier is set explicitly regardless of moveBy', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var _modifiers$flip2;
    var modifiers = (0, _modifiers.createModifiers)(_objectSpread(_objectSpread({}, defaultProps), {}, {
      moveBy: {
        x: 5,
        y: 10
      },
      flip: true
    }));
    expect(modifiers == null || (_modifiers$flip2 = modifiers.flip) == null ? void 0 : _modifiers$flip2.enabled).toEqual(true);
  }));
  it('should disable the flip modifier when set explicitly', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var _modifiers$flip3;
    var modifiers = (0, _modifiers.createModifiers)(_objectSpread(_objectSpread({}, defaultProps), {}, {
      flip: false
    }));
    expect(modifiers == null || (_modifiers$flip3 = modifiers.flip) == null ? void 0 : _modifiers$flip3.enabled).toEqual(false);
  }));
  it('should disable `preventOverflow` and `hide` when fixed set to `true`', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var _modifiers$preventOve, _modifiers$hide;
    var modifiers = (0, _modifiers.createModifiers)(_objectSpread(_objectSpread({}, defaultProps), {}, {
      fixed: true
    }));
    expect(modifiers == null || (_modifiers$preventOve = modifiers.preventOverflow) == null ? void 0 : _modifiers$preventOve.enabled).toEqual(false);
    expect(modifiers == null || (_modifiers$hide = modifiers.hide) == null ? void 0 : _modifiers$hide.enabled).toEqual(false);
  }));
  it('should disable computeStyle when isTestEnv is set to `true`', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var _modifiers$computeSty2;
    var modifiers = (0, _modifiers.createModifiers)(_objectSpread(_objectSpread({}, defaultProps), {}, {
      isTestEnv: true
    }));
    expect(modifiers == null || (_modifiers$computeSty2 = modifiers.computeStyle) == null ? void 0 : _modifiers$computeSty2.enabled).toEqual(false);
  }));
  it('should set boundariesElement when appendTo is provided', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var _modifiers$preventOve2;
    var modifiers = (0, _modifiers.createModifiers)(_objectSpread(_objectSpread({}, defaultProps), {}, {
      appendTo: 'viewport'
    }));
    expect(modifiers == null || (_modifiers$preventOve2 = modifiers.preventOverflow) == null ? void 0 : _modifiers$preventOve2.boundariesElement).toEqual('viewport');
  }));
  it('should enable setPopperWidth [when] given minWidth ', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var _modifiers$setPopperW;
    var modifiers = (0, _modifiers.createModifiers)(_objectSpread(_objectSpread({}, defaultProps), {}, {
      minWidth: '500px'
    }));
    expect(modifiers == null || (_modifiers$setPopperW = modifiers.setPopperWidth) == null ? void 0 : _modifiers$setPopperW.enabled).toEqual(true);
  }));
  it('should enable setPopperWidth [when] given dynamicWidth ', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var _modifiers$setPopperW2;
    var modifiers = (0, _modifiers.createModifiers)(_objectSpread(_objectSpread({}, defaultProps), {}, {
      dynamicWidth: true
    }));
    expect(modifiers == null || (_modifiers$setPopperW2 = modifiers.setPopperWidth) == null ? void 0 : _modifiers$setPopperW2.enabled).toEqual(true);
  }));
  describe('flipModifier', () => {
    it('should create flipVariationsOnSameSide modifier with order 599', () => {
      var _modifiers$flipVariat, _modifiers$flipVariat2, _modifiers$flipVariat3;
      var customFlipFn = vi.fn(data => data);
      var modifiers = (0, _modifiers.createModifiers)(_objectSpread(_objectSpread({}, defaultProps), {}, {
        flipModifier: customFlipFn
      }));
      expect(modifiers == null || (_modifiers$flipVariat = modifiers.flipVariationsOnSameSide) == null ? void 0 : _modifiers$flipVariat.enabled).toEqual(true);
      expect(modifiers == null || (_modifiers$flipVariat2 = modifiers.flipVariationsOnSameSide) == null ? void 0 : _modifiers$flipVariat2.order).toEqual(599);
      expect(modifiers == null || (_modifiers$flipVariat3 = modifiers.flipVariationsOnSameSide) == null ? void 0 : _modifiers$flipVariat3.fn).toBe(customFlipFn);
    });
    it('should not create flipVariationsOnSameSide when flipModifier is undefined', () => {
      var modifiers = (0, _modifiers.createModifiers)(_objectSpread({}, defaultProps));
      expect(modifiers).not.toHaveProperty('flipVariationsOnSameSide');
    });
  });
});
//# sourceMappingURL=modifiers.spec.js.map