@instructure/ui-dom-utils 10.16.1-snapshot-0 → 10.16.1-snapshot-1
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 +1 -1
- package/es/__new-tests__/addEventListener.test.js +2 -2
- package/es/__new-tests__/addInputModeListener.test.js +9 -4
- package/es/__new-tests__/addPositionChangeListener.test.js +2 -2
- package/es/__new-tests__/findTabbable.test.js +30 -15
- package/es/__new-tests__/getClassList.test.js +5 -4
- package/es/__new-tests__/getFontSize.test.js +5 -4
- package/es/__new-tests__/getOffsetParents.test.js +76 -59
- package/es/__new-tests__/getScrollParents.test.js +43 -34
- package/es/__new-tests__/isVisible.test.js +52 -37
- package/lib/__new-tests__/addEventListener.test.js +4 -5
- package/lib/__new-tests__/addInputModeListener.test.js +14 -10
- package/lib/__new-tests__/addPositionChangeListener.test.js +4 -5
- package/lib/__new-tests__/findTabbable.test.js +31 -17
- package/lib/__new-tests__/getClassList.test.js +6 -6
- package/lib/__new-tests__/getFontSize.test.js +6 -6
- package/lib/__new-tests__/getOffsetParents.test.js +78 -62
- package/lib/__new-tests__/getScrollParents.test.js +47 -39
- package/lib/__new-tests__/isVisible.test.js +59 -45
- package/package.json +4 -4
- package/src/__new-tests__/addEventListener.test.tsx +0 -1
- package/src/__new-tests__/addInputModeListener.test.tsx +0 -1
- package/src/__new-tests__/addPositionChangeListener.test.tsx +0 -1
- package/src/__new-tests__/findTabbable.test.tsx +0 -1
- package/src/__new-tests__/getClassList.test.tsx +0 -1
- package/src/__new-tests__/getFontSize.test.tsx +0 -1
- package/src/__new-tests__/getOffsetParents.test.tsx +0 -1
- package/src/__new-tests__/getScrollParents.test.tsx +0 -1
- package/src/__new-tests__/isVisible.test.tsx +0 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/__new-tests__/addEventListener.test.d.ts.map +1 -1
- package/types/__new-tests__/addInputModeListener.test.d.ts.map +1 -1
- package/types/__new-tests__/addPositionChangeListener.test.d.ts.map +1 -1
- package/types/__new-tests__/findTabbable.test.d.ts.map +1 -1
- package/types/__new-tests__/getClassList.test.d.ts.map +1 -1
- package/types/__new-tests__/getFontSize.test.d.ts.map +1 -1
- package/types/__new-tests__/getOffsetParents.test.d.ts.map +1 -1
- package/types/__new-tests__/getScrollParents.test.d.ts.map +1 -1
- package/types/__new-tests__/isVisible.test.d.ts.map +1 -1
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
|
-
## [10.16.1-snapshot-
|
|
6
|
+
## [10.16.1-snapshot-1](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1-snapshot-1) (2025-04-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-dom-utils
|
|
9
9
|
|
|
@@ -23,15 +23,15 @@ var _div;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { fireEvent, render } from '@testing-library/react';
|
|
28
27
|
import { vi } from 'vitest';
|
|
29
28
|
import '@testing-library/jest-dom';
|
|
30
29
|
import { addEventListener } from '../addEventListener';
|
|
30
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
31
31
|
describe('addEventListener', () => {
|
|
32
32
|
it('should add an event listener and provide a remove method', () => {
|
|
33
33
|
const callback = vi.fn();
|
|
34
|
-
const _render = render(_div || (_div =
|
|
34
|
+
const _render = render(_div || (_div = _jsx("div", {}))),
|
|
35
35
|
container = _render.container;
|
|
36
36
|
const node = container.firstChild;
|
|
37
37
|
const listener = addEventListener(node, 'click', callback);
|
|
@@ -23,17 +23,22 @@ var _div;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render, fireEvent, screen } from '@testing-library/react';
|
|
28
27
|
import { vi } from 'vitest';
|
|
29
28
|
import '@testing-library/jest-dom';
|
|
30
29
|
import { addInputModeListener } from '../addInputModeListener';
|
|
30
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
31
31
|
describe('addInputModeListener', () => {
|
|
32
32
|
it('should handle input mode changes', () => {
|
|
33
33
|
const handleInputModeChange = vi.fn();
|
|
34
|
-
render(_div || (_div =
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
render(_div || (_div = _jsxs("div", {
|
|
35
|
+
children: [_jsx("button", {
|
|
36
|
+
id: "button-1",
|
|
37
|
+
children: "hello"
|
|
38
|
+
}), _jsx("button", {
|
|
39
|
+
children: "world"
|
|
40
|
+
})]
|
|
41
|
+
})));
|
|
37
42
|
const inputModeListener = addInputModeListener({
|
|
38
43
|
onInputModeChange: handleInputModeChange
|
|
39
44
|
});
|
|
@@ -23,11 +23,11 @@ var _div;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render, waitFor } from '@testing-library/react';
|
|
28
27
|
import { vi } from 'vitest';
|
|
29
28
|
import '@testing-library/jest-dom';
|
|
30
29
|
import { addPositionChangeListener } from '../addPositionChangeListener';
|
|
30
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
31
31
|
const mockRect = {
|
|
32
32
|
top: 0,
|
|
33
33
|
left: 0,
|
|
@@ -43,7 +43,7 @@ describe('addPositionChangeListener', () => {
|
|
|
43
43
|
it('should provide a remove method', async () => {
|
|
44
44
|
const callback = vi.fn();
|
|
45
45
|
Element.prototype.getBoundingClientRect = vi.fn(() => mockRect);
|
|
46
|
-
const _render = render(_div || (_div =
|
|
46
|
+
const _render = render(_div || (_div = _jsx("div", {}))),
|
|
47
47
|
container = _render.container;
|
|
48
48
|
const node = container.firstChild;
|
|
49
49
|
const listener = addPositionChangeListener(node, callback);
|
|
@@ -23,26 +23,37 @@ var _a, _div, _div2, _input, _button, _button2;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render } from '@testing-library/react';
|
|
28
27
|
import '@testing-library/jest-dom';
|
|
29
28
|
import { findTabbable } from '../findTabbable';
|
|
29
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
30
30
|
describe('findTabbable', () => {
|
|
31
31
|
describe('tabbable content', () => {
|
|
32
32
|
it('should find tabbable descendants', () => {
|
|
33
|
-
const _render = render(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
const _render = render(_jsxs("div", {
|
|
34
|
+
children: [_a || (_a = _jsx("a", {
|
|
35
|
+
href: "https://instructure-test",
|
|
36
|
+
children: "Tabbable"
|
|
37
|
+
})), _div || (_div = _jsx("div", {
|
|
38
|
+
children: "Not Tabbable"
|
|
39
|
+
})), _div2 || (_div2 = _jsx("div", {
|
|
40
|
+
tabIndex: 1,
|
|
41
|
+
children: "Tabbable"
|
|
42
|
+
})), _input || (_input = _jsx("input", {
|
|
43
|
+
type: "text",
|
|
44
|
+
value: "Tabbable",
|
|
45
|
+
readOnly: true
|
|
46
|
+
})), _jsxs("div", {
|
|
47
|
+
children: [_button || (_button = _jsx("button", {
|
|
48
|
+
children: "Tabbable"
|
|
49
|
+
})), _jsx("button", {
|
|
50
|
+
style: {
|
|
51
|
+
display: 'none'
|
|
52
|
+
},
|
|
53
|
+
children: "Not Tabbable"
|
|
54
|
+
})]
|
|
55
|
+
})]
|
|
56
|
+
})),
|
|
46
57
|
container = _render.container;
|
|
47
58
|
const node = container.firstChild;
|
|
48
59
|
expect(findTabbable(node).length).toBe(4);
|
|
@@ -51,7 +62,11 @@ describe('findTabbable', () => {
|
|
|
51
62
|
describe('tabbable root', () => {
|
|
52
63
|
it('should search the root node when shouldSearchRootNode is set', () => {
|
|
53
64
|
const shouldSearchRootNode = true;
|
|
54
|
-
const _render2 = render(_button2 || (_button2 =
|
|
65
|
+
const _render2 = render(_button2 || (_button2 = _jsx("button", {
|
|
66
|
+
children: _jsx("span", {
|
|
67
|
+
children: "hello"
|
|
68
|
+
})
|
|
69
|
+
}))),
|
|
55
70
|
container = _render2.container;
|
|
56
71
|
const node = container.firstChild;
|
|
57
72
|
expect(findTabbable(node).length).toBe(0);
|
|
@@ -23,15 +23,16 @@ var _span;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render } from '@testing-library/react';
|
|
28
27
|
import '@testing-library/jest-dom';
|
|
29
28
|
import { getClassList } from '../getClassList';
|
|
29
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
30
30
|
describe('getClassList', () => {
|
|
31
31
|
it('should provide classlist methods', () => {
|
|
32
|
-
const _render = render(_span || (_span =
|
|
33
|
-
className: "foo bar baz"
|
|
34
|
-
|
|
32
|
+
const _render = render(_span || (_span = _jsx("span", {
|
|
33
|
+
className: "foo bar baz",
|
|
34
|
+
children: "Test"
|
|
35
|
+
}))),
|
|
35
36
|
container = _render.container;
|
|
36
37
|
const node = container.firstChild;
|
|
37
38
|
const classes = getClassList(node);
|
|
@@ -22,17 +22,18 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import React from 'react';
|
|
26
25
|
import { render } from '@testing-library/react';
|
|
27
26
|
import '@testing-library/jest-dom';
|
|
28
27
|
import { getFontSize } from '../getFontSize';
|
|
28
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
29
29
|
describe('getFontSize', () => {
|
|
30
30
|
it('should return font size as a number', () => {
|
|
31
|
-
const _render = render(
|
|
31
|
+
const _render = render(_jsx("span", {
|
|
32
32
|
style: {
|
|
33
33
|
fontSize: '17px'
|
|
34
|
-
}
|
|
35
|
-
|
|
34
|
+
},
|
|
35
|
+
children: "Test"
|
|
36
|
+
})),
|
|
36
37
|
container = _render.container;
|
|
37
38
|
const node = container.firstChild;
|
|
38
39
|
expect(getFontSize(node)).toBe(17);
|
|
@@ -23,69 +23,86 @@ var _div;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render } from '@testing-library/react';
|
|
28
27
|
import '@testing-library/jest-dom';
|
|
29
28
|
import { getScrollParents } from '../getScrollParents';
|
|
29
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
30
30
|
describe('getScrollParents', () => {
|
|
31
|
-
const node =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
31
|
+
const node = _jsxs("div", {
|
|
32
|
+
children: [_div || (_div = _jsx("div", {
|
|
33
|
+
id: "item-1",
|
|
34
|
+
children: _jsxs("div", {
|
|
35
|
+
id: "item-2",
|
|
36
|
+
children: [_jsx("span", {
|
|
37
|
+
id: "item-3",
|
|
38
|
+
children: "Test"
|
|
39
|
+
}), _jsx("span", {
|
|
40
|
+
id: "sibling-1",
|
|
41
|
+
children: "Test"
|
|
42
|
+
}), _jsx("span", {
|
|
43
|
+
id: "sibling-2",
|
|
44
|
+
children: "Test"
|
|
45
|
+
}), _jsx("span", {
|
|
46
|
+
id: "sibling-3",
|
|
47
|
+
children: "Test"
|
|
48
|
+
})]
|
|
49
|
+
})
|
|
50
|
+
})), _jsx("div", {
|
|
51
|
+
id: "ht",
|
|
52
|
+
style: {
|
|
53
|
+
height: '50px'
|
|
54
|
+
}
|
|
55
|
+
}), _jsx("div", {
|
|
56
|
+
id: "scroll-parent",
|
|
57
|
+
style: {
|
|
58
|
+
height: '200px',
|
|
59
|
+
overflow: 'scroll'
|
|
60
|
+
},
|
|
61
|
+
children: _jsx("div", {
|
|
62
|
+
children: _jsx("div", {
|
|
63
|
+
id: "scroll-child",
|
|
64
|
+
style: {
|
|
65
|
+
height: '500px'
|
|
66
|
+
},
|
|
67
|
+
children: "Test"
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
}), _jsx("div", {
|
|
71
|
+
id: "scroll-parent-rel",
|
|
72
|
+
style: {
|
|
73
|
+
height: '200px',
|
|
74
|
+
overflow: 'scroll',
|
|
75
|
+
position: 'relative'
|
|
76
|
+
},
|
|
77
|
+
children: _jsx("div", {
|
|
78
|
+
style: {
|
|
79
|
+
height: '200px',
|
|
80
|
+
overflow: 'scroll'
|
|
81
|
+
},
|
|
82
|
+
children: _jsx("div", {
|
|
83
|
+
id: "scroll-child-rel",
|
|
84
|
+
style: {
|
|
85
|
+
height: '500px',
|
|
86
|
+
position: 'absolute'
|
|
87
|
+
},
|
|
88
|
+
children: "Test"
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
}), _jsx("div", {
|
|
92
|
+
style: {
|
|
93
|
+
height: '200px',
|
|
94
|
+
overflow: 'scroll'
|
|
95
|
+
},
|
|
96
|
+
children: _jsx("div", {
|
|
97
|
+
id: "scroll-child-fixed",
|
|
98
|
+
style: {
|
|
99
|
+
height: '500px',
|
|
100
|
+
position: 'fixed'
|
|
101
|
+
},
|
|
102
|
+
children: "Test"
|
|
103
|
+
})
|
|
104
|
+
})]
|
|
105
|
+
});
|
|
89
106
|
beforeEach(() => {
|
|
90
107
|
render(node);
|
|
91
108
|
});
|
|
@@ -23,45 +23,54 @@ var _div, _div2;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render } from '@testing-library/react';
|
|
28
27
|
import '@testing-library/jest-dom';
|
|
29
28
|
import { getOffsetParents } from '../getOffsetParents';
|
|
29
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
30
30
|
describe('getOffsetParents', () => {
|
|
31
31
|
// At rendering, we receive the node_wrapper and the body as extra offsetParents
|
|
32
|
-
const node =
|
|
33
|
-
"data-testid": "node"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
32
|
+
const node = _jsxs("div", {
|
|
33
|
+
"data-testid": "node",
|
|
34
|
+
children: [_jsx("div", {
|
|
35
|
+
"data-testid": "child_1_wrapper_parent",
|
|
36
|
+
style: {
|
|
37
|
+
transform: '200px',
|
|
38
|
+
position: 'relative'
|
|
39
|
+
},
|
|
40
|
+
children: _jsx("div", {
|
|
41
|
+
"data-testid": "child_1_wrapper",
|
|
42
|
+
children: _jsx("div", {
|
|
43
|
+
"data-testid": "child-1",
|
|
44
|
+
style: {
|
|
45
|
+
height: '500px'
|
|
46
|
+
},
|
|
47
|
+
children: "Test"
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
}), _jsx("div", {
|
|
51
|
+
"data-testid": "child_2_wrapper_parent",
|
|
52
|
+
style: {
|
|
53
|
+
transform: '200px',
|
|
54
|
+
position: 'absolute'
|
|
55
|
+
},
|
|
56
|
+
children: _jsx("div", {
|
|
57
|
+
"data-testid": "child_2_wrapper",
|
|
58
|
+
style: {
|
|
59
|
+
position: 'absolute'
|
|
60
|
+
},
|
|
61
|
+
children: _div || (_div = _jsx("div", {
|
|
62
|
+
"data-testid": "child-2",
|
|
63
|
+
children: "Test"
|
|
64
|
+
}))
|
|
65
|
+
})
|
|
66
|
+
}), _div2 || (_div2 = _jsx("div", {
|
|
67
|
+
"data-testid": "child_3_wrapper",
|
|
68
|
+
children: _jsx("div", {
|
|
69
|
+
"data-testid": "child-3",
|
|
70
|
+
children: "Test"
|
|
71
|
+
})
|
|
72
|
+
}))]
|
|
73
|
+
});
|
|
65
74
|
it('should find offset parent for inline elements', () => {
|
|
66
75
|
const _render = render(node),
|
|
67
76
|
getByTestId = _render.getByTestId;
|
|
@@ -23,26 +23,29 @@ var _div;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render, screen } from '@testing-library/react';
|
|
28
27
|
import '@testing-library/jest-dom';
|
|
29
28
|
import { isVisible } from '../isVisible';
|
|
29
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
30
30
|
describe('isVisible', () => {
|
|
31
31
|
it('should recognize visible elements', () => {
|
|
32
|
-
render(_div || (_div =
|
|
33
|
-
"data-testid": "test"
|
|
34
|
-
|
|
32
|
+
render(_div || (_div = _jsx("div", {
|
|
33
|
+
"data-testid": "test",
|
|
34
|
+
children: "Hello world!"
|
|
35
|
+
})));
|
|
35
36
|
const element = screen.getByTestId('test');
|
|
36
37
|
expect(isVisible(element)).toBe(true);
|
|
37
38
|
});
|
|
38
39
|
it('should recognize elements with display: none', () => {
|
|
39
|
-
render(
|
|
40
|
-
"data-testid": "test"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
render(_jsx("div", {
|
|
41
|
+
"data-testid": "test",
|
|
42
|
+
children: _jsx("span", {
|
|
43
|
+
style: {
|
|
44
|
+
display: 'none'
|
|
45
|
+
},
|
|
46
|
+
children: "Hello world!"
|
|
47
|
+
})
|
|
48
|
+
}));
|
|
46
49
|
const element = screen.getByTestId('test').firstChild;
|
|
47
50
|
expect(isVisible(element)).toBe(false);
|
|
48
51
|
});
|
|
@@ -52,11 +55,13 @@ describe('isVisible', () => {
|
|
|
52
55
|
overflow: 'hidden',
|
|
53
56
|
clip: 'rect(0,0,0,0)'
|
|
54
57
|
};
|
|
55
|
-
render(
|
|
56
|
-
"data-testid": "test"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
render(_jsx("div", {
|
|
59
|
+
"data-testid": "test",
|
|
60
|
+
children: _jsx("span", {
|
|
61
|
+
style: style,
|
|
62
|
+
children: "Hello world!"
|
|
63
|
+
})
|
|
64
|
+
}));
|
|
60
65
|
const element = screen.getByTestId('test').firstChild;
|
|
61
66
|
expect(isVisible(element)).toBe(false);
|
|
62
67
|
});
|
|
@@ -66,11 +71,13 @@ describe('isVisible', () => {
|
|
|
66
71
|
overflow: 'hidden',
|
|
67
72
|
clip: 'rect(0,0,10px,0)'
|
|
68
73
|
};
|
|
69
|
-
render(
|
|
70
|
-
"data-testid": "test"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
render(_jsx("div", {
|
|
75
|
+
"data-testid": "test",
|
|
76
|
+
children: _jsx("span", {
|
|
77
|
+
style: style,
|
|
78
|
+
children: "Hello world!"
|
|
79
|
+
})
|
|
80
|
+
}));
|
|
74
81
|
const element = screen.getByTestId('test').firstChild;
|
|
75
82
|
expect(isVisible(element)).toBe(true);
|
|
76
83
|
});
|
|
@@ -78,15 +85,19 @@ describe('isVisible', () => {
|
|
|
78
85
|
const style = {
|
|
79
86
|
visibility: 'hidden'
|
|
80
87
|
};
|
|
81
|
-
render(
|
|
88
|
+
render(_jsx("div", {
|
|
82
89
|
"data-testid": "test",
|
|
83
|
-
style: style
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
style: style,
|
|
91
|
+
children: _jsx("span", {
|
|
92
|
+
children: _jsx("span", {
|
|
93
|
+
"data-testid": "test-2",
|
|
94
|
+
style: {
|
|
95
|
+
visibility: 'visible'
|
|
96
|
+
},
|
|
97
|
+
children: "Hello world!"
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
}));
|
|
90
101
|
const element = screen.getByTestId('test-2');
|
|
91
102
|
expect(isVisible(element, false)).toBe(true);
|
|
92
103
|
expect(isVisible(element)).toBe(false);
|
|
@@ -95,15 +106,19 @@ describe('isVisible', () => {
|
|
|
95
106
|
const style = {
|
|
96
107
|
visibility: 'hidden'
|
|
97
108
|
};
|
|
98
|
-
render(
|
|
109
|
+
render(_jsx("div", {
|
|
99
110
|
"data-testid": "test",
|
|
100
|
-
style: style
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
style: style,
|
|
112
|
+
children: _jsx("span", {
|
|
113
|
+
children: _jsx("span", {
|
|
114
|
+
"data-testid": "test-2",
|
|
115
|
+
style: {
|
|
116
|
+
visibility: 'visible'
|
|
117
|
+
},
|
|
118
|
+
children: "Hello world!"
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
}));
|
|
107
122
|
const element = screen.getByTestId('test-2').firstChild;
|
|
108
123
|
expect(isVisible(element, false)).toBe(true);
|
|
109
124
|
expect(isVisible(element)).toBe(false);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var _react = _interopRequireDefault(require("react"));
|
|
5
|
-
var _react2 = require("@testing-library/react");
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
6
4
|
var _vitest = require("vitest");
|
|
7
5
|
require("@testing-library/jest-dom");
|
|
8
6
|
var _addEventListener = require("../addEventListener");
|
|
7
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
9
8
|
var _div;
|
|
10
9
|
/*
|
|
11
10
|
* The MIT License (MIT)
|
|
@@ -33,11 +32,11 @@ var _div;
|
|
|
33
32
|
describe('addEventListener', () => {
|
|
34
33
|
it('should add an event listener and provide a remove method', () => {
|
|
35
34
|
const callback = _vitest.vi.fn();
|
|
36
|
-
const _render = (0,
|
|
35
|
+
const _render = (0, _react.render)(_div || (_div = (0, _jsxRuntime.jsx)("div", {}))),
|
|
37
36
|
container = _render.container;
|
|
38
37
|
const node = container.firstChild;
|
|
39
38
|
const listener = (0, _addEventListener.addEventListener)(node, 'click', callback);
|
|
40
|
-
|
|
39
|
+
_react.fireEvent.click(node);
|
|
41
40
|
expect(callback).toHaveBeenCalledTimes(1);
|
|
42
41
|
expect(typeof listener.remove).toBe('function');
|
|
43
42
|
listener.remove();
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var _react = _interopRequireDefault(require("react"));
|
|
5
|
-
var _react2 = require("@testing-library/react");
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
6
4
|
var _vitest = require("vitest");
|
|
7
5
|
require("@testing-library/jest-dom");
|
|
8
6
|
var _addInputModeListener = require("../addInputModeListener");
|
|
7
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
9
8
|
var _div;
|
|
10
9
|
/*
|
|
11
10
|
* The MIT License (MIT)
|
|
@@ -33,22 +32,27 @@ var _div;
|
|
|
33
32
|
describe('addInputModeListener', () => {
|
|
34
33
|
it('should handle input mode changes', () => {
|
|
35
34
|
const handleInputModeChange = _vitest.vi.fn();
|
|
36
|
-
(0,
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
(0, _react.render)(_div || (_div = (0, _jsxRuntime.jsxs)("div", {
|
|
36
|
+
children: [(0, _jsxRuntime.jsx)("button", {
|
|
37
|
+
id: "button-1",
|
|
38
|
+
children: "hello"
|
|
39
|
+
}), (0, _jsxRuntime.jsx)("button", {
|
|
40
|
+
children: "world"
|
|
41
|
+
})]
|
|
42
|
+
})));
|
|
39
43
|
const inputModeListener = (0, _addInputModeListener.addInputModeListener)({
|
|
40
44
|
onInputModeChange: handleInputModeChange
|
|
41
45
|
});
|
|
42
|
-
const button =
|
|
46
|
+
const button = _react.screen.getByRole('button', {
|
|
43
47
|
name: 'hello'
|
|
44
48
|
});
|
|
45
|
-
|
|
49
|
+
_react.fireEvent.mouseUp(button);
|
|
46
50
|
expect(inputModeListener.isKeyboardMode()).toBe(false);
|
|
47
|
-
|
|
51
|
+
_react.fireEvent.keyDown(button);
|
|
48
52
|
expect(inputModeListener.isKeyboardMode()).toBe(true);
|
|
49
53
|
expect(handleInputModeChange).toHaveBeenCalledTimes(2);
|
|
50
54
|
inputModeListener.remove();
|
|
51
|
-
|
|
55
|
+
_react.fireEvent.mouseUp(button);
|
|
52
56
|
expect(inputModeListener.isKeyboardMode()).toBe(true);
|
|
53
57
|
expect(handleInputModeChange).toHaveBeenCalledTimes(2);
|
|
54
58
|
});
|