import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/esm/SegmentedToggle/ToggleButton/test/ToggleButton.spec.jsx",
  _this = this;
import _regeneratorRuntime from "@babel/runtime/regenerator";
import React from 'react';
import { createRendererWithUniDriver } from '../../../utils/test-utils/react';
import ToggleButton from '../ToggleButton';
import { toggleButtonPrivateDriverFactory } from '../ToggleButton.private.uni.driver';
describe('ToggleButton', function () {
  var render = createRendererWithUniDriver(toggleButtonPrivateDriverFactory);
  it('should render', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
    var _render, driver;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          _render = render(/*#__PURE__*/React.createElement(ToggleButton, {
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 12,
              columnNumber: 31
            }
          })), driver = _render.driver;
          _context.t0 = expect;
          _context.next = 4;
          return driver.exists();
        case 4:
          _context.t1 = _context.sent;
          (0, _context.t0)(_context.t1).toBe(true);
        case 6:
        case "end":
          return _context.stop();
      }
    }, _callee);
  })));
  it('should be controlled', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
    var _render2, driver;
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) switch (_context2.prev = _context2.next) {
        case 0:
          _render2 = render(/*#__PURE__*/React.createElement(ToggleButton, {
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 17,
              columnNumber: 31
            }
          })), driver = _render2.driver;
          _context2.t0 = expect;
          _context2.next = 4;
          return driver.isSelected();
        case 4:
          _context2.t1 = _context2.sent;
          (0, _context2.t0)(_context2.t1).toBe(false);
          _context2.next = 8;
          return driver.click();
        case 8:
          _context2.t2 = expect;
          _context2.next = 11;
          return driver.isSelected();
        case 11:
          _context2.t3 = _context2.sent;
          (0, _context2.t2)(_context2.t3).toBe(false);
        case 13:
        case "end":
          return _context2.stop();
      }
    }, _callee2);
  })));
  describe("'children' prop", function () {
    it('should render string', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
      var text, _render3, driver;
      return _regeneratorRuntime.wrap(function _callee3$(_context3) {
        while (1) switch (_context3.prev = _context3.next) {
          case 0:
            text = 'Short option';
            _render3 = render(/*#__PURE__*/React.createElement(ToggleButton, {
              children: text,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 26,
                columnNumber: 33
              }
            })), driver = _render3.driver;
            _context3.t0 = expect;
            _context3.next = 5;
            return driver.getToggleText();
          case 5:
            _context3.t1 = _context3.sent;
            (0, _context3.t0)(_context3.t1).toBe(text);
          case 7:
          case "end":
            return _context3.stop();
        }
      }, _callee3);
    })));
    it('should render node', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
      var node, _render4, driver;
      return _regeneratorRuntime.wrap(function _callee4$(_context4) {
        while (1) switch (_context4.prev = _context4.next) {
          case 0:
            node = /*#__PURE__*/React.createElement("div", {
              "data-hook": "node",
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 31,
                columnNumber: 20
              }
            }, "Short option");
            _render4 = render(/*#__PURE__*/React.createElement(ToggleButton, {
              children: node,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 32,
                columnNumber: 33
              }
            })), driver = _render4.driver;
            _context4.t0 = expect;
            _context4.next = 5;
            return driver.childExists('[data-hook="node"]');
          case 5:
            _context4.t1 = _context4.sent;
            (0, _context4.t0)(_context4.t1).toBe(true);
          case 7:
          case "end":
            return _context4.stop();
        }
      }, _callee4);
    })));
  });
  describe("'prefixIcon' prop", function () {
    var prefix = /*#__PURE__*/React.createElement("div", {
      "data-hook": "prefix",
      __self: _this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 38,
        columnNumber: 20
      }
    }, "prefix");
    it("'should render 'prefix' when given", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
      var _render5, driver;
      return _regeneratorRuntime.wrap(function _callee5$(_context5) {
        while (1) switch (_context5.prev = _context5.next) {
          case 0:
            _render5 = render(/*#__PURE__*/React.createElement(ToggleButton, {
              prefixIcon: prefix,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 40,
                columnNumber: 33
              }
            })), driver = _render5.driver;
            _context5.t0 = expect;
            _context5.next = 4;
            return driver.prefixExists();
          case 4:
            _context5.t1 = _context5.sent;
            (0, _context5.t0)(_context5.t1).toBe(true);
          case 6:
          case "end":
            return _context5.stop();
        }
      }, _callee5);
    })));
  });
  describe("'onClick' prop", function () {
    it("should return when clicked", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
      var onClick, _render6, driver;
      return _regeneratorRuntime.wrap(function _callee6$(_context6) {
        while (1) switch (_context6.prev = _context6.next) {
          case 0:
            onClick = vi.fn();
            _render6 = render(/*#__PURE__*/React.createElement(ToggleButton, {
              onClick: onClick,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 48,
                columnNumber: 33
              }
            })), driver = _render6.driver;
            _context6.next = 4;
            return driver.click();
          case 4:
            expect(onClick).toHaveBeenCalled();
          case 5:
          case "end":
            return _context6.stop();
        }
      }, _callee6);
    })));
  });
  describe("'disabled' prop", function () {
    it("should disable onClick event", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
      var onClick, _render7, driver;
      return _regeneratorRuntime.wrap(function _callee7$(_context7) {
        while (1) switch (_context7.prev = _context7.next) {
          case 0:
            onClick = vi.fn();
            _render7 = render(/*#__PURE__*/React.createElement(ToggleButton, {
              disabled: true,
              onClick: onClick,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 57,
                columnNumber: 33
              }
            })), driver = _render7.driver;
            _context7.next = 4;
            return driver.click();
          case 4:
            expect(onClick).toHaveBeenCalledTimes(0);
          case 5:
          case "end":
            return _context7.stop();
        }
      }, _callee7);
    })));
  });
  describe("'selected' prop", function () {
    it("should set selection styles", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
      var _render8, driver;
      return _regeneratorRuntime.wrap(function _callee8$(_context8) {
        while (1) switch (_context8.prev = _context8.next) {
          case 0:
            _render8 = render(/*#__PURE__*/React.createElement(ToggleButton, {
              selected: true,
              "aria-checked": true,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 65,
                columnNumber: 33
              }
            })), driver = _render8.driver;
            _context8.t0 = expect;
            _context8.next = 4;
            return driver.isSelected();
          case 4:
            _context8.t1 = _context8.sent;
            (0, _context8.t0)(_context8.t1).toBe(true);
          case 6:
          case "end":
            return _context8.stop();
        }
      }, _callee8);
    })));
  });
});