@instructure/ui-tooltip 9.0.2-snapshot-6 → 9.0.2-snapshot-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [9.0.2-snapshot-6](https://github.com/instructure/instructure-ui/compare/v9.0.1...v9.0.2-snapshot-6) (2024-06-06)
6
+ ## [9.0.2-snapshot-7](https://github.com/instructure/instructure-ui/compare/v9.0.1...v9.0.2-snapshot-7) (2024-06-06)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-tooltip
9
9
 
@@ -0,0 +1,145 @@
1
+ var _Tooltip, _Tooltip2, _Tooltip3, _a, _Tooltip4, _Tooltip5, _Tooltip6, _h;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import React from 'react';
27
+ import { render, screen, waitFor } from '@testing-library/react';
28
+ import userEvent from '@testing-library/user-event';
29
+ import '@testing-library/jest-dom';
30
+
31
+ // eslint-disable-next-line no-restricted-imports
32
+ import { generateA11yTests } from '@instructure/ui-scripts/lib/test/generateA11yTests';
33
+ import { runAxeCheck } from '@instructure/ui-axe-check';
34
+ import { Tooltip } from '../index';
35
+ import TooltipExamples from '../__examples__/Tooltip.examples';
36
+ describe('<Tooltip />', () => {
37
+ it('should render', async () => {
38
+ render(_Tooltip || (_Tooltip = /*#__PURE__*/React.createElement(Tooltip, {
39
+ renderTip: "Hello"
40
+ }, /*#__PURE__*/React.createElement("a", {
41
+ href: "example.html"
42
+ }, "Hover or focus me"))));
43
+ const tip = screen.getByRole('tooltip');
44
+ expect(tip).toBeInTheDocument();
45
+ expect(tip).toHaveTextContent('Hello');
46
+ });
47
+ it('should render children', async () => {
48
+ render(_Tooltip2 || (_Tooltip2 = /*#__PURE__*/React.createElement(Tooltip, {
49
+ renderTip: "Hello"
50
+ }, /*#__PURE__*/React.createElement("a", {
51
+ "data-testid": "trigger",
52
+ href: "example.html"
53
+ }, "Hover or focus me"))));
54
+ const tip = screen.getByRole('tooltip');
55
+ const trigger = screen.getByTestId('trigger');
56
+ expect(trigger).toBeInTheDocument();
57
+ expect(trigger).toHaveTextContent('Hover or focus me');
58
+ expect(trigger).toHaveAttribute('href', 'example.html');
59
+ expect(tip).toHaveTextContent('Hello');
60
+ });
61
+ it('should have an aria-describedby attribute', async () => {
62
+ render(_Tooltip3 || (_Tooltip3 = /*#__PURE__*/React.createElement(Tooltip, {
63
+ renderTip: /*#__PURE__*/React.createElement("h2", null, "Hello")
64
+ }, /*#__PURE__*/React.createElement("a", {
65
+ "data-testid": "trigger",
66
+ href: "example.html"
67
+ }, "Hover or focus me"))));
68
+ const trigger = screen.getByTestId('trigger');
69
+ const tooltip = screen.getByRole('tooltip');
70
+ expect(trigger).toHaveAttribute('aria-describedby', tooltip.id);
71
+ });
72
+ it('should accept a function for renderTip', async () => {
73
+ render( /*#__PURE__*/React.createElement(Tooltip, {
74
+ renderTip: () => 'Hello'
75
+ }, _a || (_a = /*#__PURE__*/React.createElement("a", {
76
+ href: "example.html"
77
+ }, "Hover or focus me"))));
78
+ const content = screen.getByText('Hello');
79
+ expect(content).toBeInTheDocument();
80
+ });
81
+ describe('using as', () => {
82
+ it('should render children', async () => {
83
+ render(_Tooltip4 || (_Tooltip4 = /*#__PURE__*/React.createElement(Tooltip, {
84
+ renderTip: /*#__PURE__*/React.createElement("h2", null, "Hello"),
85
+ placement: "end",
86
+ as: "a",
87
+ href: "example.html"
88
+ }, "Hover or focus me")));
89
+ const tip = screen.getByRole('tooltip');
90
+ const trigger = screen.getByText('Hover or focus me');
91
+ expect(trigger).toBeInTheDocument();
92
+ expect(trigger).toHaveAttribute('href', 'example.html');
93
+ expect(trigger.tagName).toBe('A');
94
+ expect(tip).toBeInTheDocument();
95
+ expect(tip).toHaveTextContent('Hello');
96
+ });
97
+ it('should have an aria-describedby attribute', async () => {
98
+ render(_Tooltip5 || (_Tooltip5 = /*#__PURE__*/React.createElement(Tooltip, {
99
+ renderTip: /*#__PURE__*/React.createElement("h2", null, "Hello"),
100
+ placement: "end",
101
+ as: "a",
102
+ href: "example.html"
103
+ }, "Hover or focus me")));
104
+ const trigger = screen.getByText('Hover or focus me');
105
+ const tooltip = screen.getByRole('tooltip');
106
+ expect(trigger).toHaveAttribute('aria-describedby', tooltip.id);
107
+ });
108
+ it('should pass down the href attribute', async () => {
109
+ render(_Tooltip6 || (_Tooltip6 = /*#__PURE__*/React.createElement(Tooltip, {
110
+ renderTip: /*#__PURE__*/React.createElement("h2", null, "Hello"),
111
+ placement: "end",
112
+ as: "a",
113
+ href: "example.html"
114
+ }, "Hover or focus me")));
115
+ const link = screen.getByText('Hover or focus me');
116
+ expect(link).toHaveAttribute('href', 'example.html');
117
+ });
118
+ });
119
+ describe('using children', () => {
120
+ it('should call onClick of child', async () => {
121
+ const onClick = jest.fn();
122
+ render( /*#__PURE__*/React.createElement(Tooltip, {
123
+ renderTip: _h || (_h = /*#__PURE__*/React.createElement("h2", null, "Hello"))
124
+ }, /*#__PURE__*/React.createElement("button", {
125
+ onClick: onClick
126
+ }, "Hover or focus me")));
127
+ const button = screen.getByText('Hover or focus me');
128
+ await userEvent.click(button);
129
+ await waitFor(() => {
130
+ expect(onClick).toHaveBeenCalledTimes(1);
131
+ });
132
+ });
133
+ });
134
+ describe('with generated examples', () => {
135
+ const generatedComponents = generateA11yTests(Tooltip, TooltipExamples);
136
+ for (const component of generatedComponents) {
137
+ it(component.description, async () => {
138
+ const _render = render(component.content),
139
+ container = _render.container;
140
+ const axeCheck = await runAxeCheck(container);
141
+ expect(axeCheck).toBe(true);
142
+ });
143
+ }
144
+ });
145
+ });
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
6
+ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
7
+ require("@testing-library/jest-dom");
8
+ var _generateA11yTests = require("@instructure/ui-scripts/lib/test/generateA11yTests");
9
+ var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
10
+ var _index = require("../index");
11
+ var _Tooltip7 = _interopRequireDefault(require("../__examples__/Tooltip.examples"));
12
+ var _Tooltip, _Tooltip2, _Tooltip3, _a, _Tooltip4, _Tooltip5, _Tooltip6, _h;
13
+ /*
14
+ * The MIT License (MIT)
15
+ *
16
+ * Copyright (c) 2015 - present Instructure, Inc.
17
+ *
18
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
19
+ * of this software and associated documentation files (the "Software"), to deal
20
+ * in the Software without restriction, including without limitation the rights
21
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22
+ * copies of the Software, and to permit persons to whom the Software is
23
+ * furnished to do so, subject to the following conditions:
24
+ *
25
+ * The above copyright notice and this permission notice shall be included in all
26
+ * copies or substantial portions of the Software.
27
+ *
28
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34
+ * SOFTWARE.
35
+ */
36
+ // eslint-disable-next-line no-restricted-imports
37
+ describe('<Tooltip />', () => {
38
+ it('should render', async () => {
39
+ (0, _react2.render)(_Tooltip || (_Tooltip = /*#__PURE__*/_react.default.createElement(_index.Tooltip, {
40
+ renderTip: "Hello"
41
+ }, /*#__PURE__*/_react.default.createElement("a", {
42
+ href: "example.html"
43
+ }, "Hover or focus me"))));
44
+ const tip = _react2.screen.getByRole('tooltip');
45
+ expect(tip).toBeInTheDocument();
46
+ expect(tip).toHaveTextContent('Hello');
47
+ });
48
+ it('should render children', async () => {
49
+ (0, _react2.render)(_Tooltip2 || (_Tooltip2 = /*#__PURE__*/_react.default.createElement(_index.Tooltip, {
50
+ renderTip: "Hello"
51
+ }, /*#__PURE__*/_react.default.createElement("a", {
52
+ "data-testid": "trigger",
53
+ href: "example.html"
54
+ }, "Hover or focus me"))));
55
+ const tip = _react2.screen.getByRole('tooltip');
56
+ const trigger = _react2.screen.getByTestId('trigger');
57
+ expect(trigger).toBeInTheDocument();
58
+ expect(trigger).toHaveTextContent('Hover or focus me');
59
+ expect(trigger).toHaveAttribute('href', 'example.html');
60
+ expect(tip).toHaveTextContent('Hello');
61
+ });
62
+ it('should have an aria-describedby attribute', async () => {
63
+ (0, _react2.render)(_Tooltip3 || (_Tooltip3 = /*#__PURE__*/_react.default.createElement(_index.Tooltip, {
64
+ renderTip: /*#__PURE__*/_react.default.createElement("h2", null, "Hello")
65
+ }, /*#__PURE__*/_react.default.createElement("a", {
66
+ "data-testid": "trigger",
67
+ href: "example.html"
68
+ }, "Hover or focus me"))));
69
+ const trigger = _react2.screen.getByTestId('trigger');
70
+ const tooltip = _react2.screen.getByRole('tooltip');
71
+ expect(trigger).toHaveAttribute('aria-describedby', tooltip.id);
72
+ });
73
+ it('should accept a function for renderTip', async () => {
74
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Tooltip, {
75
+ renderTip: () => 'Hello'
76
+ }, _a || (_a = /*#__PURE__*/_react.default.createElement("a", {
77
+ href: "example.html"
78
+ }, "Hover or focus me"))));
79
+ const content = _react2.screen.getByText('Hello');
80
+ expect(content).toBeInTheDocument();
81
+ });
82
+ describe('using as', () => {
83
+ it('should render children', async () => {
84
+ (0, _react2.render)(_Tooltip4 || (_Tooltip4 = /*#__PURE__*/_react.default.createElement(_index.Tooltip, {
85
+ renderTip: /*#__PURE__*/_react.default.createElement("h2", null, "Hello"),
86
+ placement: "end",
87
+ as: "a",
88
+ href: "example.html"
89
+ }, "Hover or focus me")));
90
+ const tip = _react2.screen.getByRole('tooltip');
91
+ const trigger = _react2.screen.getByText('Hover or focus me');
92
+ expect(trigger).toBeInTheDocument();
93
+ expect(trigger).toHaveAttribute('href', 'example.html');
94
+ expect(trigger.tagName).toBe('A');
95
+ expect(tip).toBeInTheDocument();
96
+ expect(tip).toHaveTextContent('Hello');
97
+ });
98
+ it('should have an aria-describedby attribute', async () => {
99
+ (0, _react2.render)(_Tooltip5 || (_Tooltip5 = /*#__PURE__*/_react.default.createElement(_index.Tooltip, {
100
+ renderTip: /*#__PURE__*/_react.default.createElement("h2", null, "Hello"),
101
+ placement: "end",
102
+ as: "a",
103
+ href: "example.html"
104
+ }, "Hover or focus me")));
105
+ const trigger = _react2.screen.getByText('Hover or focus me');
106
+ const tooltip = _react2.screen.getByRole('tooltip');
107
+ expect(trigger).toHaveAttribute('aria-describedby', tooltip.id);
108
+ });
109
+ it('should pass down the href attribute', async () => {
110
+ (0, _react2.render)(_Tooltip6 || (_Tooltip6 = /*#__PURE__*/_react.default.createElement(_index.Tooltip, {
111
+ renderTip: /*#__PURE__*/_react.default.createElement("h2", null, "Hello"),
112
+ placement: "end",
113
+ as: "a",
114
+ href: "example.html"
115
+ }, "Hover or focus me")));
116
+ const link = _react2.screen.getByText('Hover or focus me');
117
+ expect(link).toHaveAttribute('href', 'example.html');
118
+ });
119
+ });
120
+ describe('using children', () => {
121
+ it('should call onClick of child', async () => {
122
+ const onClick = jest.fn();
123
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Tooltip, {
124
+ renderTip: _h || (_h = /*#__PURE__*/_react.default.createElement("h2", null, "Hello"))
125
+ }, /*#__PURE__*/_react.default.createElement("button", {
126
+ onClick: onClick
127
+ }, "Hover or focus me")));
128
+ const button = _react2.screen.getByText('Hover or focus me');
129
+ await _userEvent.default.click(button);
130
+ await (0, _react2.waitFor)(() => {
131
+ expect(onClick).toHaveBeenCalledTimes(1);
132
+ });
133
+ });
134
+ });
135
+ describe('with generated examples', () => {
136
+ const generatedComponents = (0, _generateA11yTests.generateA11yTests)(_index.Tooltip, _Tooltip7.default);
137
+ for (const component of generatedComponents) {
138
+ it(component.description, async () => {
139
+ const _render = (0, _react2.render)(component.content),
140
+ container = _render.container;
141
+ const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
142
+ expect(axeCheck).toBe(true);
143
+ });
144
+ }
145
+ });
146
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-tooltip",
3
- "version": "9.0.2-snapshot-6",
3
+ "version": "9.0.2-snapshot-7",
4
4
  "description": "A component for showing small text-only overlays on hover/focus.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,23 +24,28 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.24.5",
27
- "@instructure/emotion": "9.0.2-snapshot-6",
28
- "@instructure/shared-types": "9.0.2-snapshot-6",
29
- "@instructure/ui-popover": "9.0.2-snapshot-6",
30
- "@instructure/ui-position": "9.0.2-snapshot-6",
31
- "@instructure/ui-prop-types": "9.0.2-snapshot-6",
32
- "@instructure/ui-react-utils": "9.0.2-snapshot-6",
33
- "@instructure/ui-testable": "9.0.2-snapshot-6",
34
- "@instructure/ui-utils": "9.0.2-snapshot-6",
27
+ "@instructure/emotion": "9.0.2-snapshot-7",
28
+ "@instructure/shared-types": "9.0.2-snapshot-7",
29
+ "@instructure/ui-popover": "9.0.2-snapshot-7",
30
+ "@instructure/ui-position": "9.0.2-snapshot-7",
31
+ "@instructure/ui-prop-types": "9.0.2-snapshot-7",
32
+ "@instructure/ui-react-utils": "9.0.2-snapshot-7",
33
+ "@instructure/ui-testable": "9.0.2-snapshot-7",
34
+ "@instructure/ui-utils": "9.0.2-snapshot-7",
35
35
  "prop-types": "^15.8.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@instructure/ui-babel-preset": "9.0.2-snapshot-6",
39
- "@instructure/ui-color-utils": "9.0.2-snapshot-6",
40
- "@instructure/ui-test-locator": "9.0.2-snapshot-6",
41
- "@instructure/ui-test-queries": "9.0.2-snapshot-6",
42
- "@instructure/ui-test-utils": "9.0.2-snapshot-6",
43
- "@instructure/ui-themes": "9.0.2-snapshot-6"
38
+ "@instructure/ui-axe-check": "9.0.2-snapshot-7",
39
+ "@instructure/ui-babel-preset": "9.0.2-snapshot-7",
40
+ "@instructure/ui-color-utils": "9.0.2-snapshot-7",
41
+ "@instructure/ui-scripts": "9.0.2-snapshot-7",
42
+ "@instructure/ui-test-locator": "9.0.2-snapshot-7",
43
+ "@instructure/ui-test-queries": "9.0.2-snapshot-7",
44
+ "@instructure/ui-test-utils": "9.0.2-snapshot-7",
45
+ "@instructure/ui-themes": "9.0.2-snapshot-7",
46
+ "@testing-library/jest-dom": "^6.4.5",
47
+ "@testing-library/react": "^15.0.7",
48
+ "@testing-library/user-event": "^14.5.2"
44
49
  },
45
50
  "peerDependencies": {
46
51
  "react": ">=16.8 <=18"
@@ -0,0 +1,184 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React from 'react'
26
+ import { render, screen, waitFor } from '@testing-library/react'
27
+ import userEvent from '@testing-library/user-event'
28
+ import '@testing-library/jest-dom'
29
+
30
+ // eslint-disable-next-line no-restricted-imports
31
+ import { generateA11yTests } from '@instructure/ui-scripts/lib/test/generateA11yTests'
32
+ import { runAxeCheck } from '@instructure/ui-axe-check'
33
+
34
+ import { Tooltip } from '../index'
35
+ import TooltipExamples from '../__examples__/Tooltip.examples'
36
+
37
+ describe('<Tooltip />', () => {
38
+ it('should render', async () => {
39
+ render(
40
+ <Tooltip renderTip="Hello">
41
+ <a href="example.html">Hover or focus me</a>
42
+ </Tooltip>
43
+ )
44
+ const tip = screen.getByRole('tooltip')
45
+
46
+ expect(tip).toBeInTheDocument()
47
+ expect(tip).toHaveTextContent('Hello')
48
+ })
49
+
50
+ it('should render children', async () => {
51
+ render(
52
+ <Tooltip renderTip="Hello">
53
+ <a data-testid="trigger" href="example.html">
54
+ Hover or focus me
55
+ </a>
56
+ </Tooltip>
57
+ )
58
+
59
+ const tip = screen.getByRole('tooltip')
60
+ const trigger = screen.getByTestId('trigger')
61
+
62
+ expect(trigger).toBeInTheDocument()
63
+ expect(trigger).toHaveTextContent('Hover or focus me')
64
+ expect(trigger).toHaveAttribute('href', 'example.html')
65
+ expect(tip).toHaveTextContent('Hello')
66
+ })
67
+
68
+ it('should have an aria-describedby attribute', async () => {
69
+ render(
70
+ <Tooltip renderTip={<h2>Hello</h2>}>
71
+ <a data-testid="trigger" href="example.html">
72
+ Hover or focus me
73
+ </a>
74
+ </Tooltip>
75
+ )
76
+ const trigger = screen.getByTestId('trigger')
77
+ const tooltip = screen.getByRole('tooltip')
78
+
79
+ expect(trigger).toHaveAttribute('aria-describedby', tooltip.id)
80
+ })
81
+
82
+ it('should accept a function for renderTip', async () => {
83
+ render(
84
+ <Tooltip renderTip={() => 'Hello'}>
85
+ <a href="example.html">Hover or focus me</a>
86
+ </Tooltip>
87
+ )
88
+
89
+ const content = screen.getByText('Hello')
90
+
91
+ expect(content).toBeInTheDocument()
92
+ })
93
+
94
+ describe('using as', () => {
95
+ it('should render children', async () => {
96
+ render(
97
+ <Tooltip
98
+ renderTip={<h2>Hello</h2>}
99
+ placement="end"
100
+ as="a"
101
+ href="example.html"
102
+ >
103
+ Hover or focus me
104
+ </Tooltip>
105
+ )
106
+
107
+ const tip = screen.getByRole('tooltip')
108
+ const trigger = screen.getByText('Hover or focus me')
109
+
110
+ expect(trigger).toBeInTheDocument()
111
+ expect(trigger).toHaveAttribute('href', 'example.html')
112
+ expect(trigger.tagName).toBe('A')
113
+
114
+ expect(tip).toBeInTheDocument()
115
+ expect(tip).toHaveTextContent('Hello')
116
+ })
117
+
118
+ it('should have an aria-describedby attribute', async () => {
119
+ render(
120
+ <Tooltip
121
+ renderTip={<h2>Hello</h2>}
122
+ placement="end"
123
+ as="a"
124
+ href="example.html"
125
+ >
126
+ Hover or focus me
127
+ </Tooltip>
128
+ )
129
+
130
+ const trigger = screen.getByText('Hover or focus me')
131
+ const tooltip = screen.getByRole('tooltip')
132
+
133
+ expect(trigger).toHaveAttribute('aria-describedby', tooltip.id)
134
+ })
135
+
136
+ it('should pass down the href attribute', async () => {
137
+ render(
138
+ <Tooltip
139
+ renderTip={<h2>Hello</h2>}
140
+ placement="end"
141
+ as="a"
142
+ href="example.html"
143
+ >
144
+ Hover or focus me
145
+ </Tooltip>
146
+ )
147
+
148
+ const link = screen.getByText('Hover or focus me')
149
+
150
+ expect(link).toHaveAttribute('href', 'example.html')
151
+ })
152
+ })
153
+
154
+ describe('using children', () => {
155
+ it('should call onClick of child', async () => {
156
+ const onClick = jest.fn()
157
+
158
+ render(
159
+ <Tooltip renderTip={<h2>Hello</h2>}>
160
+ <button onClick={onClick}>Hover or focus me</button>
161
+ </Tooltip>
162
+ )
163
+
164
+ const button = screen.getByText('Hover or focus me')
165
+
166
+ await userEvent.click(button)
167
+
168
+ await waitFor(() => {
169
+ expect(onClick).toHaveBeenCalledTimes(1)
170
+ })
171
+ })
172
+ })
173
+
174
+ describe('with generated examples', () => {
175
+ const generatedComponents = generateA11yTests(Tooltip, TooltipExamples)
176
+ for (const component of generatedComponents) {
177
+ it(component.description, async () => {
178
+ const { container } = render(component.content)
179
+ const axeCheck = await runAxeCheck(container)
180
+ expect(axeCheck).toBe(true)
181
+ })
182
+ }
183
+ })
184
+ })
@@ -9,6 +9,7 @@
9
9
  "references": [
10
10
  { "path": "../emotion/tsconfig.build.json" },
11
11
  { "path": "../shared-types/tsconfig.build.json" },
12
+ { "path": "../ui-axe-check/tsconfig.build.json" },
12
13
  { "path": "../ui-popover/tsconfig.build.json" },
13
14
  { "path": "../ui-position/tsconfig.build.json" },
14
15
  { "path": "../ui-prop-types/tsconfig.build.json" },
@@ -20,6 +21,7 @@
20
21
  { "path": "../ui-test-queries/tsconfig.build.json" },
21
22
  { "path": "../ui-test-utils/tsconfig.build.json" },
22
23
  { "path": "../ui-utils/tsconfig.build.json" },
23
- { "path": "../ui-themes/tsconfig.build.json" }
24
+ { "path": "../ui-themes/tsconfig.build.json" },
25
+ { "path": "../ui-scripts/tsconfig.build.json" }
24
26
  ]
25
27
  }