@instructure/ui-dom-utils 10.19.2-snapshot-2 → 10.19.2-snapshot-4

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/package.json +4 -4
  3. package/tsconfig.build.tsbuildinfo +1 -1
  4. package/es/__new-tests__/addEventListener.test.js +0 -43
  5. package/es/__new-tests__/addInputModeListener.test.js +0 -58
  6. package/es/__new-tests__/addPositionChangeListener.test.js +0 -65
  7. package/es/__new-tests__/findTabbable.test.js +0 -79
  8. package/es/__new-tests__/getClassList.test.js +0 -47
  9. package/es/__new-tests__/getFontSize.test.js +0 -41
  10. package/es/__new-tests__/getOffsetParents.test.js +0 -124
  11. package/es/__new-tests__/getScrollParents.test.js +0 -96
  12. package/es/__new-tests__/isCustomElement.test.js +0 -41
  13. package/es/__new-tests__/isVisible.test.js +0 -126
  14. package/es/__new-tests__/requestAnimationFrame.test.js +0 -37
  15. package/es/__new-tests__/transformSelection.test.js +0 -67
  16. package/lib/__new-tests__/addEventListener.test.js +0 -44
  17. package/lib/__new-tests__/addInputModeListener.test.js +0 -59
  18. package/lib/__new-tests__/addPositionChangeListener.test.js +0 -66
  19. package/lib/__new-tests__/findTabbable.test.js +0 -80
  20. package/lib/__new-tests__/getClassList.test.js +0 -48
  21. package/lib/__new-tests__/getFontSize.test.js +0 -43
  22. package/lib/__new-tests__/getOffsetParents.test.js +0 -125
  23. package/lib/__new-tests__/getScrollParents.test.js +0 -97
  24. package/lib/__new-tests__/isCustomElement.test.js +0 -43
  25. package/lib/__new-tests__/isVisible.test.js +0 -127
  26. package/lib/__new-tests__/requestAnimationFrame.test.js +0 -39
  27. package/lib/__new-tests__/transformSelection.test.js +0 -69
  28. package/src/__new-tests__/addEventListener.test.tsx +0 -46
  29. package/src/__new-tests__/addInputModeListener.test.tsx +0 -60
  30. package/src/__new-tests__/addPositionChangeListener.test.tsx +0 -65
  31. package/src/__new-tests__/findTabbable.test.tsx +0 -68
  32. package/src/__new-tests__/getClassList.test.tsx +0 -46
  33. package/src/__new-tests__/getFontSize.test.tsx +0 -36
  34. package/src/__new-tests__/getOffsetParents.test.tsx +0 -98
  35. package/src/__new-tests__/getScrollParents.test.tsx +0 -83
  36. package/src/__new-tests__/isCustomElement.test.tsx +0 -45
  37. package/src/__new-tests__/isVisible.test.tsx +0 -113
  38. package/src/__new-tests__/requestAnimationFrame.test.tsx +0 -39
  39. package/src/__new-tests__/transformSelection.test.tsx +0 -80
  40. package/types/__new-tests__/addEventListener.test.d.ts +0 -2
  41. package/types/__new-tests__/addEventListener.test.d.ts.map +0 -1
  42. package/types/__new-tests__/addInputModeListener.test.d.ts +0 -2
  43. package/types/__new-tests__/addInputModeListener.test.d.ts.map +0 -1
  44. package/types/__new-tests__/addPositionChangeListener.test.d.ts +0 -2
  45. package/types/__new-tests__/addPositionChangeListener.test.d.ts.map +0 -1
  46. package/types/__new-tests__/findTabbable.test.d.ts +0 -2
  47. package/types/__new-tests__/findTabbable.test.d.ts.map +0 -1
  48. package/types/__new-tests__/getClassList.test.d.ts +0 -2
  49. package/types/__new-tests__/getClassList.test.d.ts.map +0 -1
  50. package/types/__new-tests__/getFontSize.test.d.ts +0 -2
  51. package/types/__new-tests__/getFontSize.test.d.ts.map +0 -1
  52. package/types/__new-tests__/getOffsetParents.test.d.ts +0 -2
  53. package/types/__new-tests__/getOffsetParents.test.d.ts.map +0 -1
  54. package/types/__new-tests__/getScrollParents.test.d.ts +0 -2
  55. package/types/__new-tests__/getScrollParents.test.d.ts.map +0 -1
  56. package/types/__new-tests__/isCustomElement.test.d.ts +0 -2
  57. package/types/__new-tests__/isCustomElement.test.d.ts.map +0 -1
  58. package/types/__new-tests__/isVisible.test.d.ts +0 -2
  59. package/types/__new-tests__/isVisible.test.d.ts.map +0 -1
  60. package/types/__new-tests__/requestAnimationFrame.test.d.ts +0 -2
  61. package/types/__new-tests__/requestAnimationFrame.test.d.ts.map +0 -1
  62. package/types/__new-tests__/transformSelection.test.d.ts +0 -2
  63. package/types/__new-tests__/transformSelection.test.d.ts.map +0 -1
@@ -1,65 +0,0 @@
1
- var _div;
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 { render, waitFor } from '@testing-library/react';
27
- import { vi } from 'vitest';
28
- import '@testing-library/jest-dom';
29
- import { addPositionChangeListener } from '../addPositionChangeListener';
30
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
31
- const mockRect = {
32
- top: 0,
33
- left: 0,
34
- right: 0,
35
- bottom: 0,
36
- width: 0,
37
- height: 0,
38
- x: 0,
39
- y: 0,
40
- toJSON: vi.fn()
41
- };
42
- describe('addPositionChangeListener', () => {
43
- it('should provide a remove method', async () => {
44
- const callback = vi.fn();
45
- Element.prototype.getBoundingClientRect = vi.fn(() => mockRect);
46
- const _render = render(_div || (_div = _jsx("div", {}))),
47
- container = _render.container;
48
- const node = container.firstChild;
49
- const listener = addPositionChangeListener(node, callback);
50
-
51
- // Manually trigger a position change (since JSDOM won't)
52
- Element.prototype.getBoundingClientRect = vi.fn(() => {
53
- return {
54
- ...mockRect,
55
- top: 200
56
- };
57
- });
58
- await waitFor(() => {
59
- expect(callback).toHaveBeenCalledTimes(1);
60
- expect(typeof listener.remove).toBe('function');
61
- });
62
- listener.remove();
63
- vi.restoreAllMocks();
64
- });
65
- });
@@ -1,79 +0,0 @@
1
- var _a, _div, _div2, _input, _button, _button2;
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 { render } from '@testing-library/react';
27
- import '@testing-library/jest-dom';
28
- import { findTabbable } from '../findTabbable';
29
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
30
- describe('findTabbable', () => {
31
- describe('tabbable content', () => {
32
- it('should find tabbable descendants', () => {
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
- })),
57
- container = _render.container;
58
- const node = container.firstChild;
59
- expect(findTabbable(node).length).toBe(4);
60
- });
61
- });
62
- describe('tabbable root', () => {
63
- it('should search the root node when shouldSearchRootNode is set', () => {
64
- const shouldSearchRootNode = true;
65
- const _render2 = render(_button2 || (_button2 = _jsx("button", {
66
- children: _jsx("span", {
67
- children: "hello"
68
- })
69
- }))),
70
- container = _render2.container;
71
- const node = container.firstChild;
72
- expect(findTabbable(node).length).toBe(0);
73
- expect(findTabbable(node, shouldSearchRootNode).length).toBe(1);
74
- });
75
- });
76
- it('should gracefully handle null', () => {
77
- expect(findTabbable(null).length).toBe(0);
78
- });
79
- });
@@ -1,47 +0,0 @@
1
- var _span;
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 { render } from '@testing-library/react';
27
- import '@testing-library/jest-dom';
28
- import { getClassList } from '../getClassList';
29
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
30
- describe('getClassList', () => {
31
- it('should provide classlist methods', () => {
32
- const _render = render(_span || (_span = _jsx("span", {
33
- className: "foo bar baz",
34
- children: "Test"
35
- }))),
36
- container = _render.container;
37
- const node = container.firstChild;
38
- const classes = getClassList(node);
39
- expect(classes.toArray().length).toBe(3);
40
- expect(classes.contains('foo')).toBeTruthy();
41
- expect(classes.contains('lorem')).toBeFalsy();
42
- classes.add('lorem');
43
- expect(classes.contains('lorem')).toBeTruthy();
44
- classes.remove('lorem');
45
- expect(classes.contains('lorem')).toBeFalsy();
46
- });
47
- });
@@ -1,41 +0,0 @@
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 { render } from '@testing-library/react';
26
- import '@testing-library/jest-dom';
27
- import { getFontSize } from '../getFontSize';
28
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
29
- describe('getFontSize', () => {
30
- it('should return font size as a number', () => {
31
- const _render = render(_jsx("span", {
32
- style: {
33
- fontSize: '17px'
34
- },
35
- children: "Test"
36
- })),
37
- container = _render.container;
38
- const node = container.firstChild;
39
- expect(getFontSize(node)).toBe(17);
40
- });
41
- });
@@ -1,124 +0,0 @@
1
- var _div;
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 { render } from '@testing-library/react';
27
- import '@testing-library/jest-dom';
28
- import { getScrollParents } from '../getScrollParents';
29
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
30
- describe('getScrollParents', () => {
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
- });
106
- beforeEach(() => {
107
- render(node);
108
- });
109
- it('should find scroll parent for inline elements', () => {
110
- const child = document.getElementById('scroll-child');
111
- const parent = document.getElementById('scroll-parent');
112
- expect(getScrollParents(child)[0]).toBe(parent);
113
- });
114
- it('should ignore static parents when absolute', () => {
115
- const child = document.getElementById('scroll-child-rel');
116
- const parent = document.getElementById('scroll-parent-rel');
117
- expect(getScrollParents(child)[0]).toBe(parent);
118
- });
119
- it('should handle fixed', () => {
120
- const child = document.getElementById('scroll-child-fixed');
121
- const scrollParent = getScrollParents(child)[0];
122
- expect(scrollParent).toBe(document);
123
- });
124
- });
@@ -1,96 +0,0 @@
1
- var _div, _div2;
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 { render } from '@testing-library/react';
27
- import '@testing-library/jest-dom';
28
- import { getOffsetParents } from '../getOffsetParents';
29
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
30
- describe('getOffsetParents', () => {
31
- // At rendering, we receive the node_wrapper and the body as extra offsetParents
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
- });
74
- it('should find offset parent for inline elements', () => {
75
- const _render = render(node),
76
- getByTestId = _render.getByTestId;
77
- const child = getByTestId('child-1');
78
- const parent = getByTestId('child_1_wrapper_parent');
79
- const offsetParents = getOffsetParents(child);
80
- expect(offsetParents[1]).toBe(parent);
81
- });
82
- it('should ignore static parents when absolute', () => {
83
- const _render2 = render(node),
84
- getByTestId = _render2.getByTestId;
85
- const child = getByTestId('child-2');
86
- const offsetParents = getOffsetParents(child);
87
- expect(offsetParents.length).toBe(5);
88
- });
89
- it('should handle fixed', () => {
90
- const _render3 = render(node),
91
- getByTestId = _render3.getByTestId;
92
- const child = getByTestId('child-3');
93
- const offsetParents = getOffsetParents(child);
94
- expect(offsetParents.length).toBe(4);
95
- });
96
- });
@@ -1,41 +0,0 @@
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 '@testing-library/jest-dom';
26
- import { isDefinedCustomElement } from '../isDefinedCustomElement';
27
- class TestElement extends HTMLElement {}
28
- describe('isDefinedCustomElement', () => {
29
- beforeAll(() => {
30
- customElements.define('test-element', TestElement);
31
- });
32
- it('should return true for defined elements', () => {
33
- const el = document.createElement('test-element');
34
- expect(isDefinedCustomElement(el)).toBe(true);
35
- });
36
- it('should return false for not defined elements', () => {
37
- // it is possible to create a custom element that is not defined
38
- const el = document.createElement('my-element');
39
- expect(isDefinedCustomElement(el)).toBe(false);
40
- });
41
- });
@@ -1,126 +0,0 @@
1
- var _div;
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 { render, screen } from '@testing-library/react';
27
- import '@testing-library/jest-dom';
28
- import { isVisible } from '../isVisible';
29
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
30
- describe('isVisible', () => {
31
- it('should recognize visible elements', () => {
32
- render(_div || (_div = _jsx("div", {
33
- "data-testid": "test",
34
- children: "Hello world!"
35
- })));
36
- const element = screen.getByTestId('test');
37
- expect(isVisible(element)).toBe(true);
38
- });
39
- it('should recognize elements with display: none', () => {
40
- render(_jsx("div", {
41
- "data-testid": "test",
42
- children: _jsx("span", {
43
- style: {
44
- display: 'none'
45
- },
46
- children: "Hello world!"
47
- })
48
- }));
49
- const element = screen.getByTestId('test').firstChild;
50
- expect(isVisible(element)).toBe(false);
51
- });
52
- it('should recognize elements hidden with clip', () => {
53
- const style = {
54
- position: 'absolute',
55
- overflow: 'hidden',
56
- clip: 'rect(0,0,0,0)'
57
- };
58
- render(_jsx("div", {
59
- "data-testid": "test",
60
- children: _jsx("span", {
61
- style: style,
62
- children: "Hello world!"
63
- })
64
- }));
65
- const element = screen.getByTestId('test').firstChild;
66
- expect(isVisible(element)).toBe(false);
67
- });
68
- it('should recognize clipped elements that are not hidden', () => {
69
- const style = {
70
- position: 'absolute',
71
- overflow: 'hidden',
72
- clip: 'rect(0,0,10px,0)'
73
- };
74
- render(_jsx("div", {
75
- "data-testid": "test",
76
- children: _jsx("span", {
77
- style: style,
78
- children: "Hello world!"
79
- })
80
- }));
81
- const element = screen.getByTestId('test').firstChild;
82
- expect(isVisible(element)).toBe(true);
83
- });
84
- it('should recursively check parent visibility', () => {
85
- const style = {
86
- visibility: 'hidden'
87
- };
88
- render(_jsx("div", {
89
- "data-testid": "test",
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
- }));
101
- const element = screen.getByTestId('test-2');
102
- expect(isVisible(element, false)).toBe(true);
103
- expect(isVisible(element)).toBe(false);
104
- });
105
- it('should not recursively check text nodes', () => {
106
- const style = {
107
- visibility: 'hidden'
108
- };
109
- render(_jsx("div", {
110
- "data-testid": "test",
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
- }));
122
- const element = screen.getByTestId('test-2').firstChild;
123
- expect(isVisible(element, false)).toBe(true);
124
- expect(isVisible(element)).toBe(false);
125
- });
126
- });
@@ -1,37 +0,0 @@
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 { waitFor } from '@testing-library/react';
26
- import { vi } from 'vitest';
27
- import { requestAnimationFrame } from '../requestAnimationFrame';
28
- describe('requestAnimationFrame', () => {
29
- it('should provide a cancel method', async () => {
30
- const callback = vi.fn();
31
- const raf = requestAnimationFrame(callback);
32
- await waitFor(() => {
33
- expect(callback).toHaveBeenCalledTimes(1);
34
- expect(typeof raf.cancel).toBe('function');
35
- });
36
- });
37
- });