MCPcopy Create free account
hub / github.com/ReactTooltip/react-tooltip / renderTooltip

Function renderTooltip

src/test/test-utils.js:70–99  ·  view source on GitHub ↗
({
  id = 'test-tooltip',
  anchorText = 'Hover Me',
  anchorProps = {},
  tooltipProps = {},
  anchor = <span data-tooltip-id={id}>{anchorText}</span>,
} = {})

Source from the content-addressed store, hash-verified

68}
69
70export function renderTooltip({
71 id = 'test-tooltip',
72 anchorText = 'Hover Me',
73 anchorProps = {},
74 tooltipProps = {},
75 anchor = <span data-tooltip-id={id}>{anchorText}</span>,
76} = {}) {
77 const view = render(
78 <>
79 {React.isValidElement(anchor)
80 ? React.cloneElement(anchor, {
81 'data-tooltip-id': anchor.props['data-tooltip-id'] ?? id,
82 ...anchorProps,
83 })
84 : anchor}
85 <TooltipController id={id} content={`${id} content`} {...tooltipProps} />
86 </>,
87 )
88
89 const getAnchor = () =>
90 anchorProps['aria-label']
91 ? screen.getByLabelText(anchorProps['aria-label'])
92 : screen.getByText(anchorText)
93
94 return {
95 ...view,
96 id,
97 getAnchor,
98 }
99}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected