@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.
- package/CHANGELOG.md +1 -1
- package/package.json +4 -4
- package/tsconfig.build.tsbuildinfo +1 -1
- package/es/__new-tests__/addEventListener.test.js +0 -43
- package/es/__new-tests__/addInputModeListener.test.js +0 -58
- package/es/__new-tests__/addPositionChangeListener.test.js +0 -65
- package/es/__new-tests__/findTabbable.test.js +0 -79
- package/es/__new-tests__/getClassList.test.js +0 -47
- package/es/__new-tests__/getFontSize.test.js +0 -41
- package/es/__new-tests__/getOffsetParents.test.js +0 -124
- package/es/__new-tests__/getScrollParents.test.js +0 -96
- package/es/__new-tests__/isCustomElement.test.js +0 -41
- package/es/__new-tests__/isVisible.test.js +0 -126
- package/es/__new-tests__/requestAnimationFrame.test.js +0 -37
- package/es/__new-tests__/transformSelection.test.js +0 -67
- package/lib/__new-tests__/addEventListener.test.js +0 -44
- package/lib/__new-tests__/addInputModeListener.test.js +0 -59
- package/lib/__new-tests__/addPositionChangeListener.test.js +0 -66
- package/lib/__new-tests__/findTabbable.test.js +0 -80
- package/lib/__new-tests__/getClassList.test.js +0 -48
- package/lib/__new-tests__/getFontSize.test.js +0 -43
- package/lib/__new-tests__/getOffsetParents.test.js +0 -125
- package/lib/__new-tests__/getScrollParents.test.js +0 -97
- package/lib/__new-tests__/isCustomElement.test.js +0 -43
- package/lib/__new-tests__/isVisible.test.js +0 -127
- package/lib/__new-tests__/requestAnimationFrame.test.js +0 -39
- package/lib/__new-tests__/transformSelection.test.js +0 -69
- package/src/__new-tests__/addEventListener.test.tsx +0 -46
- package/src/__new-tests__/addInputModeListener.test.tsx +0 -60
- package/src/__new-tests__/addPositionChangeListener.test.tsx +0 -65
- package/src/__new-tests__/findTabbable.test.tsx +0 -68
- package/src/__new-tests__/getClassList.test.tsx +0 -46
- package/src/__new-tests__/getFontSize.test.tsx +0 -36
- package/src/__new-tests__/getOffsetParents.test.tsx +0 -98
- package/src/__new-tests__/getScrollParents.test.tsx +0 -83
- package/src/__new-tests__/isCustomElement.test.tsx +0 -45
- package/src/__new-tests__/isVisible.test.tsx +0 -113
- package/src/__new-tests__/requestAnimationFrame.test.tsx +0 -39
- package/src/__new-tests__/transformSelection.test.tsx +0 -80
- package/types/__new-tests__/addEventListener.test.d.ts +0 -2
- package/types/__new-tests__/addEventListener.test.d.ts.map +0 -1
- package/types/__new-tests__/addInputModeListener.test.d.ts +0 -2
- package/types/__new-tests__/addInputModeListener.test.d.ts.map +0 -1
- package/types/__new-tests__/addPositionChangeListener.test.d.ts +0 -2
- package/types/__new-tests__/addPositionChangeListener.test.d.ts.map +0 -1
- package/types/__new-tests__/findTabbable.test.d.ts +0 -2
- package/types/__new-tests__/findTabbable.test.d.ts.map +0 -1
- package/types/__new-tests__/getClassList.test.d.ts +0 -2
- package/types/__new-tests__/getClassList.test.d.ts.map +0 -1
- package/types/__new-tests__/getFontSize.test.d.ts +0 -2
- package/types/__new-tests__/getFontSize.test.d.ts.map +0 -1
- package/types/__new-tests__/getOffsetParents.test.d.ts +0 -2
- package/types/__new-tests__/getOffsetParents.test.d.ts.map +0 -1
- package/types/__new-tests__/getScrollParents.test.d.ts +0 -2
- package/types/__new-tests__/getScrollParents.test.d.ts.map +0 -1
- package/types/__new-tests__/isCustomElement.test.d.ts +0 -2
- package/types/__new-tests__/isCustomElement.test.d.ts.map +0 -1
- package/types/__new-tests__/isVisible.test.d.ts +0 -2
- package/types/__new-tests__/isVisible.test.d.ts.map +0 -1
- package/types/__new-tests__/requestAnimationFrame.test.d.ts +0 -2
- package/types/__new-tests__/requestAnimationFrame.test.d.ts.map +0 -1
- package/types/__new-tests__/transformSelection.test.d.ts +0 -2
- package/types/__new-tests__/transformSelection.test.d.ts.map +0 -1
|
@@ -1,67 +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 { transformSelection, transformCursor } from '../transformSelection';
|
|
26
|
-
describe('transformSelection', () => {
|
|
27
|
-
it('should work with transformCursor', () => {
|
|
28
|
-
const paramObj = {
|
|
29
|
-
selectionStart: 2,
|
|
30
|
-
selectionEnd: 3,
|
|
31
|
-
selectionDirection: 'none',
|
|
32
|
-
value: '1x2345'
|
|
33
|
-
};
|
|
34
|
-
const result = transformSelection(paramObj, '12345');
|
|
35
|
-
expect(result).toEqual({
|
|
36
|
-
selectionStart: 1,
|
|
37
|
-
selectionEnd: 2,
|
|
38
|
-
selectionDirection: 'none'
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
describe('transformCursor', () => {
|
|
43
|
-
it('should retain cursor at the end', () => {
|
|
44
|
-
const dirtyValue = '12_xxxx_';
|
|
45
|
-
const cleanedValue = '12';
|
|
46
|
-
const cursorIndex = dirtyValue.length;
|
|
47
|
-
expect(transformCursor(cursorIndex, dirtyValue, cleanedValue)).toBe(cleanedValue.length);
|
|
48
|
-
});
|
|
49
|
-
it('should retain cursor at the start', () => {
|
|
50
|
-
const dirtyValue = '12_xxxx_67';
|
|
51
|
-
const cleanedValue = '1267';
|
|
52
|
-
const cursorIndex = 0;
|
|
53
|
-
expect(transformCursor(cursorIndex, dirtyValue, cleanedValue)).toBe(0);
|
|
54
|
-
});
|
|
55
|
-
it('should retain cursor between cleaned values', () => {
|
|
56
|
-
const dirtyValue = '12_xxxx_67';
|
|
57
|
-
const cleanedValue = '1267';
|
|
58
|
-
const cursorIndex = 6;
|
|
59
|
-
expect(transformCursor(cursorIndex, dirtyValue, cleanedValue)).toBe(2);
|
|
60
|
-
});
|
|
61
|
-
it('should retain cursor after cleaned values', () => {
|
|
62
|
-
const dirtyValue = '12_xxxx_67';
|
|
63
|
-
const cleanedValue = '1267';
|
|
64
|
-
const cursorIndex = dirtyValue.length - 1;
|
|
65
|
-
expect(transformCursor(cursorIndex, dirtyValue, cleanedValue)).toBe(3);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
var _vitest = require("vitest");
|
|
5
|
-
require("@testing-library/jest-dom");
|
|
6
|
-
var _addEventListener = require("../addEventListener");
|
|
7
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
8
|
-
var _div;
|
|
9
|
-
/*
|
|
10
|
-
* The MIT License (MIT)
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
19
|
-
* furnished to do so, subject to the following conditions:
|
|
20
|
-
*
|
|
21
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
22
|
-
* copies or substantial portions of the Software.
|
|
23
|
-
*
|
|
24
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
-
* SOFTWARE.
|
|
31
|
-
*/
|
|
32
|
-
describe('addEventListener', () => {
|
|
33
|
-
it('should add an event listener and provide a remove method', () => {
|
|
34
|
-
const callback = _vitest.vi.fn();
|
|
35
|
-
const _render = (0, _react.render)(_div || (_div = (0, _jsxRuntime.jsx)("div", {}))),
|
|
36
|
-
container = _render.container;
|
|
37
|
-
const node = container.firstChild;
|
|
38
|
-
const listener = (0, _addEventListener.addEventListener)(node, 'click', callback);
|
|
39
|
-
_react.fireEvent.click(node);
|
|
40
|
-
expect(callback).toHaveBeenCalledTimes(1);
|
|
41
|
-
expect(typeof listener.remove).toBe('function');
|
|
42
|
-
listener.remove();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
var _vitest = require("vitest");
|
|
5
|
-
require("@testing-library/jest-dom");
|
|
6
|
-
var _addInputModeListener = require("../addInputModeListener");
|
|
7
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
8
|
-
var _div;
|
|
9
|
-
/*
|
|
10
|
-
* The MIT License (MIT)
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
19
|
-
* furnished to do so, subject to the following conditions:
|
|
20
|
-
*
|
|
21
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
22
|
-
* copies or substantial portions of the Software.
|
|
23
|
-
*
|
|
24
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
-
* SOFTWARE.
|
|
31
|
-
*/
|
|
32
|
-
describe('addInputModeListener', () => {
|
|
33
|
-
it('should handle input mode changes', () => {
|
|
34
|
-
const handleInputModeChange = _vitest.vi.fn();
|
|
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
|
-
})));
|
|
43
|
-
const inputModeListener = (0, _addInputModeListener.addInputModeListener)({
|
|
44
|
-
onInputModeChange: handleInputModeChange
|
|
45
|
-
});
|
|
46
|
-
const button = _react.screen.getByRole('button', {
|
|
47
|
-
name: 'hello'
|
|
48
|
-
});
|
|
49
|
-
_react.fireEvent.mouseUp(button);
|
|
50
|
-
expect(inputModeListener.isKeyboardMode()).toBe(false);
|
|
51
|
-
_react.fireEvent.keyDown(button);
|
|
52
|
-
expect(inputModeListener.isKeyboardMode()).toBe(true);
|
|
53
|
-
expect(handleInputModeChange).toHaveBeenCalledTimes(2);
|
|
54
|
-
inputModeListener.remove();
|
|
55
|
-
_react.fireEvent.mouseUp(button);
|
|
56
|
-
expect(inputModeListener.isKeyboardMode()).toBe(true);
|
|
57
|
-
expect(handleInputModeChange).toHaveBeenCalledTimes(2);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
var _vitest = require("vitest");
|
|
5
|
-
require("@testing-library/jest-dom");
|
|
6
|
-
var _addPositionChangeListener = require("../addPositionChangeListener");
|
|
7
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
8
|
-
var _div;
|
|
9
|
-
/*
|
|
10
|
-
* The MIT License (MIT)
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
19
|
-
* furnished to do so, subject to the following conditions:
|
|
20
|
-
*
|
|
21
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
22
|
-
* copies or substantial portions of the Software.
|
|
23
|
-
*
|
|
24
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
-
* SOFTWARE.
|
|
31
|
-
*/
|
|
32
|
-
const mockRect = {
|
|
33
|
-
top: 0,
|
|
34
|
-
left: 0,
|
|
35
|
-
right: 0,
|
|
36
|
-
bottom: 0,
|
|
37
|
-
width: 0,
|
|
38
|
-
height: 0,
|
|
39
|
-
x: 0,
|
|
40
|
-
y: 0,
|
|
41
|
-
toJSON: _vitest.vi.fn()
|
|
42
|
-
};
|
|
43
|
-
describe('addPositionChangeListener', () => {
|
|
44
|
-
it('should provide a remove method', async () => {
|
|
45
|
-
const callback = _vitest.vi.fn();
|
|
46
|
-
Element.prototype.getBoundingClientRect = _vitest.vi.fn(() => mockRect);
|
|
47
|
-
const _render = (0, _react.render)(_div || (_div = (0, _jsxRuntime.jsx)("div", {}))),
|
|
48
|
-
container = _render.container;
|
|
49
|
-
const node = container.firstChild;
|
|
50
|
-
const listener = (0, _addPositionChangeListener.addPositionChangeListener)(node, callback);
|
|
51
|
-
|
|
52
|
-
// Manually trigger a position change (since JSDOM won't)
|
|
53
|
-
Element.prototype.getBoundingClientRect = _vitest.vi.fn(() => {
|
|
54
|
-
return {
|
|
55
|
-
...mockRect,
|
|
56
|
-
top: 200
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
await (0, _react.waitFor)(() => {
|
|
60
|
-
expect(callback).toHaveBeenCalledTimes(1);
|
|
61
|
-
expect(typeof listener.remove).toBe('function');
|
|
62
|
-
});
|
|
63
|
-
listener.remove();
|
|
64
|
-
_vitest.vi.restoreAllMocks();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
require("@testing-library/jest-dom");
|
|
5
|
-
var _findTabbable = require("../findTabbable");
|
|
6
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
7
|
-
var _a, _div, _div2, _input, _button, _button2;
|
|
8
|
-
/*
|
|
9
|
-
* The MIT License (MIT)
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
-
*
|
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
-
* in the Software without restriction, including without limitation the rights
|
|
16
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
-
* furnished to do so, subject to the following conditions:
|
|
19
|
-
*
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
-
* copies or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
-
* SOFTWARE.
|
|
30
|
-
*/
|
|
31
|
-
describe('findTabbable', () => {
|
|
32
|
-
describe('tabbable content', () => {
|
|
33
|
-
it('should find tabbable descendants', () => {
|
|
34
|
-
const _render = (0, _react.render)((0, _jsxRuntime.jsxs)("div", {
|
|
35
|
-
children: [_a || (_a = (0, _jsxRuntime.jsx)("a", {
|
|
36
|
-
href: "https://instructure-test",
|
|
37
|
-
children: "Tabbable"
|
|
38
|
-
})), _div || (_div = (0, _jsxRuntime.jsx)("div", {
|
|
39
|
-
children: "Not Tabbable"
|
|
40
|
-
})), _div2 || (_div2 = (0, _jsxRuntime.jsx)("div", {
|
|
41
|
-
tabIndex: 1,
|
|
42
|
-
children: "Tabbable"
|
|
43
|
-
})), _input || (_input = (0, _jsxRuntime.jsx)("input", {
|
|
44
|
-
type: "text",
|
|
45
|
-
value: "Tabbable",
|
|
46
|
-
readOnly: true
|
|
47
|
-
})), (0, _jsxRuntime.jsxs)("div", {
|
|
48
|
-
children: [_button || (_button = (0, _jsxRuntime.jsx)("button", {
|
|
49
|
-
children: "Tabbable"
|
|
50
|
-
})), (0, _jsxRuntime.jsx)("button", {
|
|
51
|
-
style: {
|
|
52
|
-
display: 'none'
|
|
53
|
-
},
|
|
54
|
-
children: "Not Tabbable"
|
|
55
|
-
})]
|
|
56
|
-
})]
|
|
57
|
-
})),
|
|
58
|
-
container = _render.container;
|
|
59
|
-
const node = container.firstChild;
|
|
60
|
-
expect((0, _findTabbable.findTabbable)(node).length).toBe(4);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
describe('tabbable root', () => {
|
|
64
|
-
it('should search the root node when shouldSearchRootNode is set', () => {
|
|
65
|
-
const shouldSearchRootNode = true;
|
|
66
|
-
const _render2 = (0, _react.render)(_button2 || (_button2 = (0, _jsxRuntime.jsx)("button", {
|
|
67
|
-
children: (0, _jsxRuntime.jsx)("span", {
|
|
68
|
-
children: "hello"
|
|
69
|
-
})
|
|
70
|
-
}))),
|
|
71
|
-
container = _render2.container;
|
|
72
|
-
const node = container.firstChild;
|
|
73
|
-
expect((0, _findTabbable.findTabbable)(node).length).toBe(0);
|
|
74
|
-
expect((0, _findTabbable.findTabbable)(node, shouldSearchRootNode).length).toBe(1);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
it('should gracefully handle null', () => {
|
|
78
|
-
expect((0, _findTabbable.findTabbable)(null).length).toBe(0);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
require("@testing-library/jest-dom");
|
|
5
|
-
var _getClassList = require("../getClassList");
|
|
6
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
7
|
-
var _span;
|
|
8
|
-
/*
|
|
9
|
-
* The MIT License (MIT)
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
-
*
|
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
-
* in the Software without restriction, including without limitation the rights
|
|
16
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
-
* furnished to do so, subject to the following conditions:
|
|
19
|
-
*
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
-
* copies or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
-
* SOFTWARE.
|
|
30
|
-
*/
|
|
31
|
-
describe('getClassList', () => {
|
|
32
|
-
it('should provide classlist methods', () => {
|
|
33
|
-
const _render = (0, _react.render)(_span || (_span = (0, _jsxRuntime.jsx)("span", {
|
|
34
|
-
className: "foo bar baz",
|
|
35
|
-
children: "Test"
|
|
36
|
-
}))),
|
|
37
|
-
container = _render.container;
|
|
38
|
-
const node = container.firstChild;
|
|
39
|
-
const classes = (0, _getClassList.getClassList)(node);
|
|
40
|
-
expect(classes.toArray().length).toBe(3);
|
|
41
|
-
expect(classes.contains('foo')).toBeTruthy();
|
|
42
|
-
expect(classes.contains('lorem')).toBeFalsy();
|
|
43
|
-
classes.add('lorem');
|
|
44
|
-
expect(classes.contains('lorem')).toBeTruthy();
|
|
45
|
-
classes.remove('lorem');
|
|
46
|
-
expect(classes.contains('lorem')).toBeFalsy();
|
|
47
|
-
});
|
|
48
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
require("@testing-library/jest-dom");
|
|
5
|
-
var _getFontSize = require("../getFontSize");
|
|
6
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
7
|
-
/*
|
|
8
|
-
* The MIT License (MIT)
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
-
*
|
|
12
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
-
* in the Software without restriction, including without limitation the rights
|
|
15
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
-
* furnished to do so, subject to the following conditions:
|
|
18
|
-
*
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
* copies or substantial portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
-
* SOFTWARE.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
describe('getFontSize', () => {
|
|
32
|
-
it('should return font size as a number', () => {
|
|
33
|
-
const _render = (0, _react.render)((0, _jsxRuntime.jsx)("span", {
|
|
34
|
-
style: {
|
|
35
|
-
fontSize: '17px'
|
|
36
|
-
},
|
|
37
|
-
children: "Test"
|
|
38
|
-
})),
|
|
39
|
-
container = _render.container;
|
|
40
|
-
const node = container.firstChild;
|
|
41
|
-
expect((0, _getFontSize.getFontSize)(node)).toBe(17);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
require("@testing-library/jest-dom");
|
|
5
|
-
var _getScrollParents = require("../getScrollParents");
|
|
6
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
7
|
-
var _div;
|
|
8
|
-
/*
|
|
9
|
-
* The MIT License (MIT)
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
-
*
|
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
-
* in the Software without restriction, including without limitation the rights
|
|
16
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
-
* furnished to do so, subject to the following conditions:
|
|
19
|
-
*
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
-
* copies or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
-
* SOFTWARE.
|
|
30
|
-
*/
|
|
31
|
-
describe('getScrollParents', () => {
|
|
32
|
-
const node = (0, _jsxRuntime.jsxs)("div", {
|
|
33
|
-
children: [_div || (_div = (0, _jsxRuntime.jsx)("div", {
|
|
34
|
-
id: "item-1",
|
|
35
|
-
children: (0, _jsxRuntime.jsxs)("div", {
|
|
36
|
-
id: "item-2",
|
|
37
|
-
children: [(0, _jsxRuntime.jsx)("span", {
|
|
38
|
-
id: "item-3",
|
|
39
|
-
children: "Test"
|
|
40
|
-
}), (0, _jsxRuntime.jsx)("span", {
|
|
41
|
-
id: "sibling-1",
|
|
42
|
-
children: "Test"
|
|
43
|
-
}), (0, _jsxRuntime.jsx)("span", {
|
|
44
|
-
id: "sibling-2",
|
|
45
|
-
children: "Test"
|
|
46
|
-
}), (0, _jsxRuntime.jsx)("span", {
|
|
47
|
-
id: "sibling-3",
|
|
48
|
-
children: "Test"
|
|
49
|
-
})]
|
|
50
|
-
})
|
|
51
|
-
})), (0, _jsxRuntime.jsx)("div", {
|
|
52
|
-
id: "ht",
|
|
53
|
-
style: {
|
|
54
|
-
height: '50px'
|
|
55
|
-
}
|
|
56
|
-
}), (0, _jsxRuntime.jsx)("div", {
|
|
57
|
-
id: "scroll-parent",
|
|
58
|
-
style: {
|
|
59
|
-
height: '200px',
|
|
60
|
-
overflow: 'scroll'
|
|
61
|
-
},
|
|
62
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
63
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
64
|
-
id: "scroll-child",
|
|
65
|
-
style: {
|
|
66
|
-
height: '500px'
|
|
67
|
-
},
|
|
68
|
-
children: "Test"
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
}), (0, _jsxRuntime.jsx)("div", {
|
|
72
|
-
id: "scroll-parent-rel",
|
|
73
|
-
style: {
|
|
74
|
-
height: '200px',
|
|
75
|
-
overflow: 'scroll',
|
|
76
|
-
position: 'relative'
|
|
77
|
-
},
|
|
78
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
79
|
-
style: {
|
|
80
|
-
height: '200px',
|
|
81
|
-
overflow: 'scroll'
|
|
82
|
-
},
|
|
83
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
84
|
-
id: "scroll-child-rel",
|
|
85
|
-
style: {
|
|
86
|
-
height: '500px',
|
|
87
|
-
position: 'absolute'
|
|
88
|
-
},
|
|
89
|
-
children: "Test"
|
|
90
|
-
})
|
|
91
|
-
})
|
|
92
|
-
}), (0, _jsxRuntime.jsx)("div", {
|
|
93
|
-
style: {
|
|
94
|
-
height: '200px',
|
|
95
|
-
overflow: 'scroll'
|
|
96
|
-
},
|
|
97
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
98
|
-
id: "scroll-child-fixed",
|
|
99
|
-
style: {
|
|
100
|
-
height: '500px',
|
|
101
|
-
position: 'fixed'
|
|
102
|
-
},
|
|
103
|
-
children: "Test"
|
|
104
|
-
})
|
|
105
|
-
})]
|
|
106
|
-
});
|
|
107
|
-
beforeEach(() => {
|
|
108
|
-
(0, _react.render)(node);
|
|
109
|
-
});
|
|
110
|
-
it('should find scroll parent for inline elements', () => {
|
|
111
|
-
const child = document.getElementById('scroll-child');
|
|
112
|
-
const parent = document.getElementById('scroll-parent');
|
|
113
|
-
expect((0, _getScrollParents.getScrollParents)(child)[0]).toBe(parent);
|
|
114
|
-
});
|
|
115
|
-
it('should ignore static parents when absolute', () => {
|
|
116
|
-
const child = document.getElementById('scroll-child-rel');
|
|
117
|
-
const parent = document.getElementById('scroll-parent-rel');
|
|
118
|
-
expect((0, _getScrollParents.getScrollParents)(child)[0]).toBe(parent);
|
|
119
|
-
});
|
|
120
|
-
it('should handle fixed', () => {
|
|
121
|
-
const child = document.getElementById('scroll-child-fixed');
|
|
122
|
-
const scrollParent = (0, _getScrollParents.getScrollParents)(child)[0];
|
|
123
|
-
expect(scrollParent).toBe(document);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
require("@testing-library/jest-dom");
|
|
5
|
-
var _getOffsetParents = require("../getOffsetParents");
|
|
6
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
7
|
-
var _div, _div2;
|
|
8
|
-
/*
|
|
9
|
-
* The MIT License (MIT)
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
-
*
|
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
-
* in the Software without restriction, including without limitation the rights
|
|
16
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
-
* furnished to do so, subject to the following conditions:
|
|
19
|
-
*
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
-
* copies or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
-
* SOFTWARE.
|
|
30
|
-
*/
|
|
31
|
-
describe('getOffsetParents', () => {
|
|
32
|
-
// At rendering, we receive the node_wrapper and the body as extra offsetParents
|
|
33
|
-
const node = (0, _jsxRuntime.jsxs)("div", {
|
|
34
|
-
"data-testid": "node",
|
|
35
|
-
children: [(0, _jsxRuntime.jsx)("div", {
|
|
36
|
-
"data-testid": "child_1_wrapper_parent",
|
|
37
|
-
style: {
|
|
38
|
-
transform: '200px',
|
|
39
|
-
position: 'relative'
|
|
40
|
-
},
|
|
41
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
42
|
-
"data-testid": "child_1_wrapper",
|
|
43
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
44
|
-
"data-testid": "child-1",
|
|
45
|
-
style: {
|
|
46
|
-
height: '500px'
|
|
47
|
-
},
|
|
48
|
-
children: "Test"
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
}), (0, _jsxRuntime.jsx)("div", {
|
|
52
|
-
"data-testid": "child_2_wrapper_parent",
|
|
53
|
-
style: {
|
|
54
|
-
transform: '200px',
|
|
55
|
-
position: 'absolute'
|
|
56
|
-
},
|
|
57
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
58
|
-
"data-testid": "child_2_wrapper",
|
|
59
|
-
style: {
|
|
60
|
-
position: 'absolute'
|
|
61
|
-
},
|
|
62
|
-
children: _div || (_div = (0, _jsxRuntime.jsx)("div", {
|
|
63
|
-
"data-testid": "child-2",
|
|
64
|
-
children: "Test"
|
|
65
|
-
}))
|
|
66
|
-
})
|
|
67
|
-
}), _div2 || (_div2 = (0, _jsxRuntime.jsx)("div", {
|
|
68
|
-
"data-testid": "child_3_wrapper",
|
|
69
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
70
|
-
"data-testid": "child-3",
|
|
71
|
-
children: "Test"
|
|
72
|
-
})
|
|
73
|
-
}))]
|
|
74
|
-
});
|
|
75
|
-
it('should find offset parent for inline elements', () => {
|
|
76
|
-
const _render = (0, _react.render)(node),
|
|
77
|
-
getByTestId = _render.getByTestId;
|
|
78
|
-
const child = getByTestId('child-1');
|
|
79
|
-
const parent = getByTestId('child_1_wrapper_parent');
|
|
80
|
-
const offsetParents = (0, _getOffsetParents.getOffsetParents)(child);
|
|
81
|
-
expect(offsetParents[1]).toBe(parent);
|
|
82
|
-
});
|
|
83
|
-
it('should ignore static parents when absolute', () => {
|
|
84
|
-
const _render2 = (0, _react.render)(node),
|
|
85
|
-
getByTestId = _render2.getByTestId;
|
|
86
|
-
const child = getByTestId('child-2');
|
|
87
|
-
const offsetParents = (0, _getOffsetParents.getOffsetParents)(child);
|
|
88
|
-
expect(offsetParents.length).toBe(5);
|
|
89
|
-
});
|
|
90
|
-
it('should handle fixed', () => {
|
|
91
|
-
const _render3 = (0, _react.render)(node),
|
|
92
|
-
getByTestId = _render3.getByTestId;
|
|
93
|
-
const child = getByTestId('child-3');
|
|
94
|
-
const offsetParents = (0, _getOffsetParents.getOffsetParents)(child);
|
|
95
|
-
expect(offsetParents.length).toBe(4);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("@testing-library/jest-dom");
|
|
4
|
-
var _isDefinedCustomElement = require("../isDefinedCustomElement");
|
|
5
|
-
/*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
*
|
|
8
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
9
|
-
*
|
|
10
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
* in the Software without restriction, including without limitation the rights
|
|
13
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
* furnished to do so, subject to the following conditions:
|
|
16
|
-
*
|
|
17
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
18
|
-
* copies or substantial portions of the Software.
|
|
19
|
-
*
|
|
20
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
-
* SOFTWARE.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
class TestElement extends HTMLElement {}
|
|
30
|
-
describe('isDefinedCustomElement', () => {
|
|
31
|
-
beforeAll(() => {
|
|
32
|
-
customElements.define('test-element', TestElement);
|
|
33
|
-
});
|
|
34
|
-
it('should return true for defined elements', () => {
|
|
35
|
-
const el = document.createElement('test-element');
|
|
36
|
-
expect((0, _isDefinedCustomElement.isDefinedCustomElement)(el)).toBe(true);
|
|
37
|
-
});
|
|
38
|
-
it('should return false for not defined elements', () => {
|
|
39
|
-
// it is possible to create a custom element that is not defined
|
|
40
|
-
const el = document.createElement('my-element');
|
|
41
|
-
expect((0, _isDefinedCustomElement.isDefinedCustomElement)(el)).toBe(false);
|
|
42
|
-
});
|
|
43
|
-
});
|