"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));
var _vanilla = require("@wix/wix-ui-test-utils/vanilla");
var _testUtils2 = require("../utils/test-utils");
var _Text = _interopRequireDefault(require("../Text/Text.driver"));
var _Checkbox = _interopRequireDefault(require("../Checkbox/Checkbox.driver"));
var textTestkitFactory = (0, _vanilla.testkitFactoryCreator)(_Text.default);
var checkboxTestkitFactory = (0, _vanilla.testkitFactoryCreator)(_Checkbox.default);
var selectorDriverFactory = _ref => {
  var {
    element
  } = _ref;
  var toggleInput = () => element.querySelector('[data-hook="toggle"] input');
  var image = () => element.querySelector('[data-hook="selector-image"]');
  var titleTextDriver = () => textTestkitFactory({
    wrapper: element,
    dataHook: 'selector-title'
  });
  var subtitleTextDriver = () => textTestkitFactory({
    wrapper: element,
    dataHook: 'selector-subtitle'
  });
  var extraNode = () => element.querySelector('[data-hook="selector-extra-node"]');
  var checkboxDriver = () => checkboxTestkitFactory({
    wrapper: element,
    dataHook: 'toggle'
  });
  return {
    exists: () => !!element,
    isImageTiny: () => (0, _testUtils2.isClassExists)(image(), 'tiny'),
    isImageSmall: () => (0, _testUtils2.isClassExists)(image(), 'small'),
    isImagePortrait: () => (0, _testUtils2.isClassExists)(image(), 'portrait'),
    isImageLarge: () => (0, _testUtils2.isClassExists)(image(), 'large'),
    isImageCinema: () => (0, _testUtils2.isClassExists)(image(), 'cinema'),
    isImageCircle: () => (0, _testUtils2.isClassExists)(image(), 'circle'),
    isImageRectangular: () => (0, _testUtils2.isClassExists)(image(), 'rectangular'),
    isDisabled: () => toggleInput().disabled,
    isIndeterminate: () => checkboxDriver().isIndeterminate(),
    toggleType: () => toggleInput().type,
    isChecked: () => !!toggleInput().checked,
    hasImage: () => !!image(),
    getImage: () => image().childNodes[0],
    titleTextDriver,
    subtitleTextDriver,
    hasExtraNode: () => !!extraNode(),
    getExtraNode: () => extraNode().childNodes[0],
    toggle: () => _testUtils.default.Simulate.click(element)
  };
};
var _default = exports.default = selectorDriverFactory;
//# sourceMappingURL=Selector.driver.js.map