-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Expand file tree
/
Copy pathTooltip.test.js
More file actions
50 lines (41 loc) · 1.27 KB
/
Tooltip.test.js
File metadata and controls
50 lines (41 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { expect } from 'chai';
import { createRenderer, screen, isJsdom, act, fireEvent } from '@mui/internal-test-utils';
import Tooltip from '@mui/material/Tooltip';
import Input from '@mui/material/Input';
function focusVisibleSync(element) {
act(() => {
element.blur();
});
fireEvent.keyDown(document.body, { key: 'Tab' });
act(() => {
element.focus();
});
}
describe('<Tooltip> integration', () => {
const { render } = createRenderer();
it.skipIf(isJsdom())(
'does not throw error and closes Tooltip when Input becomes disabled while focused',
() => {
function TestCase({ disabled }) {
return (
<Tooltip
title="Test"
enterDelay={0}
leaveDelay={0}
slotProps={{ transition: { timeout: 0 } }}
>
<Input disabled={disabled} placeholder="click here and wait" />
</Tooltip>
);
}
const { setProps } = render(<TestCase disabled={false} />);
const input = screen.getByRole('textbox');
focusVisibleSync(input);
expect(screen.getByRole('tooltip')).toBeVisible();
expect(() => {
setProps({ disabled: true });
}).not.to.throw();
expect(screen.getByRole('tooltip')).not.toBeVisible();
},
);
});