UNPKG

@atlaskit/tooltip

Version:

A tooltip briefly describes an interactive element on mouse hover or keyboard focus.

43 lines (42 loc) • 1.49 kB
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; import _regeneratorRuntime from "@babel/runtime/regenerator"; import { flushPopoverExit } from '@atlaskit/top-layer/testing/flush-popover-exit'; /** * Waits for a tooltip that has started hiding to finish hiding in jsdom. * * Requires React 18.3 or newer. * * With `platform-dst-top-layer-tooltip` on, the tooltip hides through a top-layer * `Popover`, which jest fake timers alone cannot flush - see * `@atlaskit/top-layer/testing/flush-popover-exit`, which this delegates to. * * Call this after the hide `delay` has been flushed. * * @example * await user.unhover(trigger); * // flush the hide delay * act(() => { * jest.runOnlyPendingTimers(); * }); * await waitForTooltipToHide(); * expect(screen.queryByTestId('tooltip')).not.toBeInTheDocument(); * expect(onHide).toHaveBeenCalledTimes(1); */ export function waitForTooltipToHide() { return _waitForTooltipToHide.apply(this, arguments); } function _waitForTooltipToHide() { _waitForTooltipToHide = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { return _regeneratorRuntime.wrap(function (_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 1; return flushPopoverExit(); case 1: case "end": return _context.stop(); } }, _callee); })); return _waitForTooltipToHide.apply(this, arguments); }