UNPKG

@wix/design-system

Version:

@wix/design-system

1,124 lines 49.3 kB
import _extends from "@babel/runtime/helpers/extends"; import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/esm/FloatingHelper/ClosablePopover/test/ClosablePopover.spec.jsx", _this = this; import _regeneratorRuntime from "@babel/runtime/regenerator"; import React from 'react'; import { closablePopoverUniDriverFactory } from '../ClosablePopover.uni.driver'; import ClosablePopover from '../ClosablePopover'; import { act, createRendererWithUniDriver, cleanup, waitFor } from '../../../utils/test-utils/react/index'; describe('ClosablePopover', function () { var requiredProps = { target: /*#__PURE__*/React.createElement("div", { __self: _this, __source: { fileName: _jsxFileName, lineNumber: 13, columnNumber: 13 } }, "this is the target"), content: function content() { return /*#__PURE__*/React.createElement("div", { __self: _this, __source: { fileName: _jsxFileName, lineNumber: 14, columnNumber: 20 } }, "this is the popover content"); }, placement: 'right' }; describe('[async]', function () { runTests(createRendererWithUniDriver(closablePopoverUniDriverFactory)); }); function runTests(render) { var _this2 = this; afterEach(function () { return cleanup(); }); describe('open/close on hover', function () { it('should display content on hover and hide it on leave, after closed', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { var triggerClose, props, _render, driver; return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: props = { content: function content(_ref2) { var close = _ref2.close; triggerClose = close; return /*#__PURE__*/React.createElement("div", { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 31, columnNumber: 20 } }, "the content"); } }; _render = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 36, columnNumber: 11 } }))), driver = _render.driver; _context3.next = 4; return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() { return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return triggerClose(); case 2: case "end": return _context.stop(); } }, _callee); }))); case 4: _context3.next = 6; return driver.mouseEnter(); case 6: _context3.t0 = expect; _context3.next = 9; return driver.isContentElementExists(); case 9: _context3.t1 = _context3.sent; (0, _context3.t0)(_context3.t1).toBe(true); _context3.next = 13; return driver.mouseLeave(); case 13: _context3.next = 15; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.t0 = expect; _context2.next = 3; return driver.isContentElementExists(); case 3: _context2.t1 = _context2.sent; return _context2.abrupt("return", (0, _context2.t0)(_context2.t1).toBe(false)); case 5: case "end": return _context2.stop(); } }, _callee2); }))); case 15: case "end": return _context3.stop(); } }, _callee3); }))); it('should NOT close on mouse leave when initially opened', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() { var _render2, driver; return _regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: _render2 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 50, columnNumber: 35 } }))), driver = _render2.driver; _context6.next = 3; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() { return _regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: _context4.t0 = expect; _context4.next = 3; return driver.isTargetElementExists(); case 3: _context4.t1 = _context4.sent; return _context4.abrupt("return", (0, _context4.t0)(_context4.t1).toBe(true)); case 5: case "end": return _context4.stop(); } }, _callee4); }))); case 3: _context6.next = 5; return driver.mouseEnter(); case 5: _context6.next = 7; return driver.mouseLeave(); case 7: _context6.next = 9; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() { return _regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: _context5.t0 = expect; _context5.next = 3; return driver.isContentElementExists(); case 3: _context5.t1 = _context5.sent; return _context5.abrupt("return", (0, _context5.t0)(_context5.t1).toBe(true)); case 5: case "end": return _context5.stop(); } }, _callee5); }))); case 9: case "end": return _context6.stop(); } }, _callee6); }))); it('should display content on hover and hide it on leave, when initially closed', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8() { var props, _render3, driver; return _regeneratorRuntime.wrap(function _callee8$(_context8) { while (1) switch (_context8.prev = _context8.next) { case 0: props = { initiallyOpened: false }; _render3 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 69, columnNumber: 11 } }))), driver = _render3.driver; _context8.next = 4; return driver.mouseEnter(); case 4: _context8.t0 = expect; _context8.next = 7; return driver.isContentElementExists(); case 7: _context8.t1 = _context8.sent; (0, _context8.t0)(_context8.t1).toBe(true); _context8.next = 11; return driver.mouseLeave(); case 11: _context8.next = 13; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() { return _regeneratorRuntime.wrap(function _callee7$(_context7) { while (1) switch (_context7.prev = _context7.next) { case 0: _context7.t0 = expect; _context7.next = 3; return driver.isContentElementExists(); case 3: _context7.t1 = _context7.sent; return _context7.abrupt("return", (0, _context7.t0)(_context7.t1).toBe(false)); case 5: case "end": return _context7.stop(); } }, _callee7); }))); case 13: case "end": return _context8.stop(); } }, _callee8); }))); it('should not hide on mouse-leave, given closeOnMouseLeave is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10() { var triggerClose, props, _render4, driver; return _regeneratorRuntime.wrap(function _callee10$(_context10) { while (1) switch (_context10.prev = _context10.next) { case 0: props = { content: function content(_ref1) { var close = _ref1.close; triggerClose = close; return /*#__PURE__*/React.createElement("div", { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 85, columnNumber: 20 } }, "the content"); }, initiallyOpened: true, closeOnMouseLeave: false }; _render4 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 92, columnNumber: 11 } }))), driver = _render4.driver; _context10.next = 4; return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9() { return _regeneratorRuntime.wrap(function _callee9$(_context9) { while (1) switch (_context9.prev = _context9.next) { case 0: _context9.next = 2; return triggerClose(); case 2: case "end": return _context9.stop(); } }, _callee9); }))); case 4: _context10.next = 6; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0() { return _regeneratorRuntime.wrap(function _callee0$(_context0) { while (1) switch (_context0.prev = _context0.next) { case 0: _context0.t0 = expect; _context0.next = 3; return driver.isContentElementExists(); case 3: _context0.t1 = _context0.sent; return _context0.abrupt("return", (0, _context0.t0)(_context0.t1).toBe(false)); case 5: case "end": return _context0.stop(); } }, _callee0); }))); case 6: _context10.next = 8; return driver.mouseEnter(); case 8: _context10.t0 = expect; _context10.next = 11; return driver.isContentElementExists(); case 11: _context10.t1 = _context10.sent; (0, _context10.t0)(_context10.t1).toBe(true); _context10.next = 15; return driver.mouseLeave(); case 15: _context10.next = 17; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1() { return _regeneratorRuntime.wrap(function _callee1$(_context1) { while (1) switch (_context1.prev = _context1.next) { case 0: _context1.t0 = expect; _context1.next = 3; return driver.isContentElementExists(); case 3: _context1.t1 = _context1.sent; return _context1.abrupt("return", (0, _context1.t0)(_context1.t1).toBe(true)); case 5: case "end": return _context1.stop(); } }, _callee1); }))); case 17: case "end": return _context10.stop(); } }, _callee10); }))); }); describe('onOpened/onClosed callbacks', function () { it('should call onClosed when closed by close-action', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12() { var triggerClose, props, _render5, driver; return _regeneratorRuntime.wrap(function _callee12$(_context12) { while (1) switch (_context12.prev = _context12.next) { case 0: props = { onClose: vi.fn(), content: function content(_ref14) { var close = _ref14.close; triggerClose = close; return /*#__PURE__*/React.createElement("div", { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 117, columnNumber: 20 } }, "the content"); } }; _render5 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 122, columnNumber: 11 } }))), driver = _render5.driver; _context12.next = 4; return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11() { return _regeneratorRuntime.wrap(function _callee11$(_context11) { while (1) switch (_context11.prev = _context11.next) { case 0: _context11.next = 2; return triggerClose(); case 2: case "end": return _context11.stop(); } }, _callee11); }))); case 4: expect(props.onClose).toHaveBeenCalled(); case 5: case "end": return _context12.stop(); } }, _callee12); }))); it('should call onOpened when hovered by mouse', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14() { var triggerClose, props, _render6, driver; return _regeneratorRuntime.wrap(function _callee14$(_context14) { while (1) switch (_context14.prev = _context14.next) { case 0: props = { content: function content(_ref17) { var close = _ref17.close; triggerClose = close; return /*#__PURE__*/React.createElement("div", { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 138, columnNumber: 20 } }, "the content"); }, onOpen: vi.fn() }; _render6 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 144, columnNumber: 11 } }))), driver = _render6.driver; _context14.next = 4; return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13() { return _regeneratorRuntime.wrap(function _callee13$(_context13) { while (1) switch (_context13.prev = _context13.next) { case 0: _context13.next = 2; return triggerClose(); case 2: case "end": return _context13.stop(); } }, _callee13); }))); case 4: _context14.next = 6; return driver.mouseEnter(); case 6: expect(props.onOpen).toHaveBeenCalled(); case 7: case "end": return _context14.stop(); } }, _callee14); }))); it('should call onClosed when mouse leaves after closed by close-action', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee16() { var triggerClose, props, _render7, driver; return _regeneratorRuntime.wrap(function _callee16$(_context16) { while (1) switch (_context16.prev = _context16.next) { case 0: props = { content: function content(_ref20) { var close = _ref20.close; triggerClose = close; return /*#__PURE__*/React.createElement("div", { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 160, columnNumber: 20 } }, "the content"); }, onClose: vi.fn() }; _render7 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 166, columnNumber: 11 } }))), driver = _render7.driver; _context16.next = 4; return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15() { return _regeneratorRuntime.wrap(function _callee15$(_context15) { while (1) switch (_context15.prev = _context15.next) { case 0: _context15.next = 2; return triggerClose(); case 2: case "end": return _context15.stop(); } }, _callee15); }))); case 4: _context16.next = 6; return driver.mouseEnter(); case 6: _context16.next = 8; return driver.mouseLeave(); case 8: expect(props.onClose.mock.calls.length).toBe(2); case 9: case "end": return _context16.stop(); } }, _callee16); }))); }); describe('initiallyOpened', function () { it('should be initially opened', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee18() { var props, _render8, driver; return _regeneratorRuntime.wrap(function _callee18$(_context18) { while (1) switch (_context18.prev = _context18.next) { case 0: props = { initiallyOpened: true }; _render8 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 184, columnNumber: 11 } }))), driver = _render8.driver; _context18.next = 4; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee17() { return _regeneratorRuntime.wrap(function _callee17$(_context17) { while (1) switch (_context17.prev = _context17.next) { case 0: _context17.t0 = expect; _context17.next = 3; return driver.isOpened(); case 3: _context17.t1 = _context17.sent; return _context17.abrupt("return", (0, _context17.t0)(_context17.t1).toBe(true)); case 5: case "end": return _context17.stop(); } }, _callee17); }))); case 4: case "end": return _context18.stop(); } }, _callee18); }))); it('should be initially closed', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee19() { var props, _render9, driver; return _regeneratorRuntime.wrap(function _callee19$(_context19) { while (1) switch (_context19.prev = _context19.next) { case 0: props = { initiallyOpened: false }; _render9 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 194, columnNumber: 11 } }))), driver = _render9.driver; _context19.t0 = expect; _context19.next = 5; return driver.isOpened(); case 5: _context19.t1 = _context19.sent; (0, _context19.t0)(_context19.t1).toBe(false); case 7: case "end": return _context19.stop(); } }, _callee19); }))); it('should NOT close on mouse leave when initially opened', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee22() { var _render0, driver; return _regeneratorRuntime.wrap(function _callee22$(_context22) { while (1) switch (_context22.prev = _context22.next) { case 0: _render0 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 200, columnNumber: 35 } }))), driver = _render0.driver; _context22.next = 3; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee20() { return _regeneratorRuntime.wrap(function _callee20$(_context20) { while (1) switch (_context20.prev = _context20.next) { case 0: _context20.t0 = expect; _context20.next = 3; return driver.isTargetElementExists(); case 3: _context20.t1 = _context20.sent; return _context20.abrupt("return", (0, _context20.t0)(_context20.t1).toBe(true)); case 5: case "end": return _context20.stop(); } }, _callee20); }))); case 3: _context22.next = 5; return driver.mouseEnter(); case 5: _context22.next = 7; return driver.mouseLeave(); case 7: _context22.next = 9; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee21() { return _regeneratorRuntime.wrap(function _callee21$(_context21) { while (1) switch (_context21.prev = _context21.next) { case 0: _context21.t0 = expect; _context21.next = 3; return driver.isContentElementExists(); case 3: _context21.t1 = _context21.sent; return _context21.abrupt("return", (0, _context21.t0)(_context21.t1).toBe(true)); case 5: case "end": return _context21.stop(); } }, _callee21); }))); case 9: case "end": return _context22.stop(); } }, _callee22); }))); }); describe('close', function () { it('should be opened by default', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee24() { var _render1, driver; return _regeneratorRuntime.wrap(function _callee24$(_context24) { while (1) switch (_context24.prev = _context24.next) { case 0: _render1 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 216, columnNumber: 35 } }))), driver = _render1.driver; _context24.next = 3; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee23() { return _regeneratorRuntime.wrap(function _callee23$(_context23) { while (1) switch (_context23.prev = _context23.next) { case 0: _context23.t0 = expect; _context23.next = 3; return driver.isOpened(); case 3: _context23.t1 = _context23.sent; return _context23.abrupt("return", (0, _context23.t0)(_context23.t1).toBe(true)); case 5: case "end": return _context23.stop(); } }, _callee23); }))); case 3: case "end": return _context24.stop(); } }, _callee24); }))); it('should close when closeAction called', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee28() { var triggerClose, props, _render10, driver; return _regeneratorRuntime.wrap(function _callee28$(_context28) { while (1) switch (_context28.prev = _context28.next) { case 0: props = { content: function content(_ref31) { var close = _ref31.close; triggerClose = close; return /*#__PURE__*/React.createElement("div", { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 225, columnNumber: 20 } }, "the content"); } }; _render10 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 229, columnNumber: 11 } }))), driver = _render10.driver; _context28.next = 4; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee25() { return _regeneratorRuntime.wrap(function _callee25$(_context25) { while (1) switch (_context25.prev = _context25.next) { case 0: _context25.t0 = expect; _context25.next = 3; return driver.isOpened(); case 3: _context25.t1 = _context25.sent; return _context25.abrupt("return", (0, _context25.t0)(_context25.t1).toBe(true)); case 5: case "end": return _context25.stop(); } }, _callee25); }))); case 4: _context28.next = 6; return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee26() { return _regeneratorRuntime.wrap(function _callee26$(_context26) { while (1) switch (_context26.prev = _context26.next) { case 0: _context26.next = 2; return triggerClose(); case 2: return _context26.abrupt("return", _context26.sent); case 3: case "end": return _context26.stop(); } }, _callee26); }))); case 6: _context28.next = 8; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee27() { return _regeneratorRuntime.wrap(function _callee27$(_context27) { while (1) switch (_context27.prev = _context27.next) { case 0: _context27.t0 = expect; _context27.next = 3; return driver.isOpened(); case 3: _context27.t1 = _context27.sent; return _context27.abrupt("return", (0, _context27.t0)(_context27.t1).toBe(false)); case 5: case "end": return _context27.stop(); } }, _callee27); }))); case 8: case "end": return _context28.stop(); } }, _callee28); }))); }); describe('ref', function () { describe('open & close ', function () { it('should be able to open through ref [when] initially closed', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee30() { var ref, props, _render11, driver; return _regeneratorRuntime.wrap(function _callee30$(_context30) { while (1) switch (_context30.prev = _context30.next) { case 0: ref = /*#__PURE__*/React.createRef(); props = { initiallyOpened: false }; _render11 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({ ref: ref }, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 246, columnNumber: 13 } }))), driver = _render11.driver; _context30.t0 = expect; _context30.next = 6; return driver.isOpened(); case 6: _context30.t1 = _context30.sent; (0, _context30.t0)(_context30.t1).toBe(false); _context30.next = 10; return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee29() { return _regeneratorRuntime.wrap(function _callee29$(_context29) { while (1) switch (_context29.prev = _context29.next) { case 0: _context29.next = 2; return ref.current.open(); case 2: case "end": return _context29.stop(); } }, _callee29); }))); case 10: _context30.t2 = expect; _context30.next = 13; return driver.isOpened(); case 13: _context30.t3 = _context30.sent; (0, _context30.t2)(_context30.t3).toBe(true); case 15: case "end": return _context30.stop(); } }, _callee30); }))); it('should be able to close through ref [when] initially opened', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee34() { var ref, props, _render12, driver; return _regeneratorRuntime.wrap(function _callee34$(_context34) { while (1) switch (_context34.prev = _context34.next) { case 0: ref = /*#__PURE__*/React.createRef(); props = { initiallyOpened: true }; _render12 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({ ref: ref }, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 263, columnNumber: 13 } }))), driver = _render12.driver; _context34.next = 5; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee31() { return _regeneratorRuntime.wrap(function _callee31$(_context31) { while (1) switch (_context31.prev = _context31.next) { case 0: _context31.t0 = expect; _context31.next = 3; return driver.isOpened(); case 3: _context31.t1 = _context31.sent; return _context31.abrupt("return", (0, _context31.t0)(_context31.t1).toBe(true)); case 5: case "end": return _context31.stop(); } }, _callee31); }))); case 5: _context34.next = 7; return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee32() { return _regeneratorRuntime.wrap(function _callee32$(_context32) { while (1) switch (_context32.prev = _context32.next) { case 0: return _context32.abrupt("return", ref.current.close()); case 1: case "end": return _context32.stop(); } }, _callee32); }))); case 7: _context34.next = 9; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee33() { return _regeneratorRuntime.wrap(function _callee33$(_context33) { while (1) switch (_context33.prev = _context33.next) { case 0: _context33.t0 = expect; _context33.next = 3; return driver.isOpened(); case 3: _context33.t1 = _context33.sent; return _context33.abrupt("return", (0, _context33.t0)(_context33.t1).toBe(false)); case 5: case "end": return _context33.stop(); } }, _callee33); }))); case 9: case "end": return _context34.stop(); } }, _callee34); }))); it('should NOT close on mouseLeave, after programmatic open [when] initially closed', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee37() { var ref, props, _render13, driver; return _regeneratorRuntime.wrap(function _callee37$(_context37) { while (1) switch (_context37.prev = _context37.next) { case 0: ref = /*#__PURE__*/React.createRef(); props = { initiallyOpened: false }; _render13 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({ ref: ref }, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 280, columnNumber: 13 } }))), driver = _render13.driver; _context37.t0 = expect; _context37.next = 6; return driver.isOpened(); case 6: _context37.t1 = _context37.sent; (0, _context37.t0)(_context37.t1).toBe(false); _context37.next = 10; return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee35() { return _regeneratorRuntime.wrap(function _callee35$(_context35) { while (1) switch (_context35.prev = _context35.next) { case 0: return _context35.abrupt("return", ref.current.open()); case 1: case "end": return _context35.stop(); } }, _callee35); }))); case 10: _context37.t2 = expect; _context37.next = 13; return driver.isOpened(); case 13: _context37.t3 = _context37.sent; (0, _context37.t2)(_context37.t3).toBe(true); _context37.next = 17; return driver.mouseEnter(); case 17: _context37.next = 19; return driver.mouseLeave(); case 19: _context37.next = 21; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee36() { return _regeneratorRuntime.wrap(function _callee36$(_context36) { while (1) switch (_context36.prev = _context36.next) { case 0: _context36.t0 = expect; _context36.next = 3; return driver.isContentElementExists(); case 3: _context36.t1 = _context36.sent; return _context36.abrupt("return", (0, _context36.t0)(_context36.t1).toBe(true)); case 5: case "end": return _context36.stop(); } }, _callee36); }))); case 21: case "end": return _context37.stop(); } }, _callee37); }))); it('should open/close on hover after click to close, after programmatic open', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee41() { var triggerClose, ref, props, _render14, driver; return _regeneratorRuntime.wrap(function _callee41$(_context41) { while (1) switch (_context41.prev = _context41.next) { case 0: ref = /*#__PURE__*/React.createRef(); props = { initiallyOpened: false, content: function content(_ref45) { var close = _ref45.close; triggerClose = close; return /*#__PURE__*/React.createElement("div", { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 305, columnNumber: 22 } }, "the content"); } }; _render14 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({ ref: ref }, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 310, columnNumber: 13 } }))), driver = _render14.driver; _context41.next = 5; return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee38() { return _regeneratorRuntime.wrap(function _callee38$(_context38) { while (1) switch (_context38.prev = _context38.next) { case 0: _context38.next = 2; return ref.current.open(); case 2: case "end": return _context38.stop(); } }, _callee38); }))); case 5: _context41.next = 7; return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee39() { return _regeneratorRuntime.wrap(function _callee39$(_context39) { while (1) switch (_context39.prev = _context39.next) { case 0: _context39.next = 2; return triggerClose(); case 2: case "end": return _context39.stop(); } }, _callee39); }))); case 7: _context41.next = 9; return driver.mouseEnter(); case 9: _context41.t0 = expect; _context41.next = 12; return driver.isContentElementExists(); case 12: _context41.t1 = _context41.sent; (0, _context41.t0)(_context41.t1).toBe(true); _context41.next = 16; return driver.mouseLeave(); case 16: _context41.next = 18; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee40() { return _regeneratorRuntime.wrap(function _callee40$(_context40) { while (1) switch (_context40.prev = _context40.next) { case 0: _context40.t0 = expect; _context40.next = 3; return driver.isContentElementExists(); case 3: _context40.t1 = _context40.sent; return _context40.abrupt("return", (0, _context40.t0)(_context40.t1).toBe(false)); case 5: case "end": return _context40.stop(); } }, _callee40); }))); case 18: case "end": return _context41.stop(); } }, _callee41); }))); }); describe('controlled', function () { it('should be opened', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee43() { var props, _render15, driver; return _regeneratorRuntime.wrap(function _callee43$(_context43) { while (1) switch (_context43.prev = _context43.next) { case 0: props = { opened: true }; _render15 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 338, columnNumber: 13 } }))), driver = _render15.driver; _context43.next = 4; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee42() { return _regeneratorRuntime.wrap(function _callee42$(_context42) { while (1) switch (_context42.prev = _context42.next) { case 0: _context42.t0 = expect; _context42.next = 3; return driver.isTargetElementExists(); case 3: _context42.t1 = _context42.sent; return _context42.abrupt("return", (0, _context42.t0)(_context42.t1).toBe(true)); case 5: case "end": return _context42.stop(); } }, _callee42); }))); case 4: _context43.t0 = expect; _context43.next = 7; return driver.isOpened(); case 7: _context43.t1 = _context43.sent; (0, _context43.t0)(_context43.t1).toBe(true); case 9: case "end": return _context43.stop(); } }, _callee43); }))); it('should be closed', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee45() { var props, _render16, driver; return _regeneratorRuntime.wrap(function _callee45$(_context45) { while (1) switch (_context45.prev = _context45.next) { case 0: props = { opened: false }; _render16 = render(/*#__PURE__*/React.createElement(ClosablePopover, _extends({}, requiredProps, props, { __self: _this2, __source: { fileName: _jsxFileName, lineNumber: 351, columnNumber: 13 } }))), driver = _render16.driver; _context45.next = 4; return waitFor(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee44() { return _regeneratorRuntime.wrap(function _callee44$(_context44) { while (1) switch (_context44.prev = _context44.next) { case 0: _context44.t0 = expect; _context44.next = 3; return driver.isTargetElementExists(); case 3: _context44.t1 = _context44.sent; return _context44.abrupt("return", (0, _context44.t0)(_context44.t1).toBe(true)); case 5: case "end": return _context44.stop(); } }, _callee44); }))); case 4: _context45.t0 = expect; _context45.next = 7; return driver.isOpened(); case 7: _context45.t1 = _context45.sent; (0, _context45.t0)(_context45.t1).toBe(false); case 9: case "end": return _context45.stop(); } }, _callee45); }))); }); }); } });