@instructure/ui-react-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 (53) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/package.json +7 -7
  3. package/tsconfig.build.tsbuildinfo +1 -1
  4. package/es/__new-tests__/DeterministicIdContext.test.js +0 -109
  5. package/es/__new-tests__/callRenderProp.test.js +0 -138
  6. package/es/__new-tests__/deprecated.test.js +0 -237
  7. package/es/__new-tests__/experimental.test.js +0 -98
  8. package/es/__new-tests__/getInteraction.test.js +0 -117
  9. package/es/__new-tests__/hack.test.js +0 -70
  10. package/es/__new-tests__/omitProps.test.js +0 -91
  11. package/es/__new-tests__/passthroughProps.test.js +0 -100
  12. package/es/__new-tests__/pickProps.test.js +0 -95
  13. package/es/__new-tests__/safeCloneElement.test.js +0 -87
  14. package/lib/__new-tests__/DeterministicIdContext.test.js +0 -110
  15. package/lib/__new-tests__/callRenderProp.test.js +0 -140
  16. package/lib/__new-tests__/deprecated.test.js +0 -240
  17. package/lib/__new-tests__/experimental.test.js +0 -101
  18. package/lib/__new-tests__/getInteraction.test.js +0 -119
  19. package/lib/__new-tests__/hack.test.js +0 -73
  20. package/lib/__new-tests__/omitProps.test.js +0 -94
  21. package/lib/__new-tests__/passthroughProps.test.js +0 -102
  22. package/lib/__new-tests__/pickProps.test.js +0 -98
  23. package/lib/__new-tests__/safeCloneElement.test.js +0 -89
  24. package/src/__new-tests__/DeterministicIdContext.test.tsx +0 -140
  25. package/src/__new-tests__/callRenderProp.test.tsx +0 -136
  26. package/src/__new-tests__/deprecated.test.tsx +0 -358
  27. package/src/__new-tests__/experimental.test.tsx +0 -139
  28. package/src/__new-tests__/getInteraction.test.tsx +0 -119
  29. package/src/__new-tests__/hack.test.tsx +0 -91
  30. package/src/__new-tests__/omitProps.test.tsx +0 -113
  31. package/src/__new-tests__/passthroughProps.test.tsx +0 -100
  32. package/src/__new-tests__/pickProps.test.tsx +0 -111
  33. package/src/__new-tests__/safeCloneElement.test.tsx +0 -96
  34. package/types/__new-tests__/DeterministicIdContext.test.d.ts +0 -2
  35. package/types/__new-tests__/DeterministicIdContext.test.d.ts.map +0 -1
  36. package/types/__new-tests__/callRenderProp.test.d.ts +0 -2
  37. package/types/__new-tests__/callRenderProp.test.d.ts.map +0 -1
  38. package/types/__new-tests__/deprecated.test.d.ts +0 -2
  39. package/types/__new-tests__/deprecated.test.d.ts.map +0 -1
  40. package/types/__new-tests__/experimental.test.d.ts +0 -2
  41. package/types/__new-tests__/experimental.test.d.ts.map +0 -1
  42. package/types/__new-tests__/getInteraction.test.d.ts +0 -2
  43. package/types/__new-tests__/getInteraction.test.d.ts.map +0 -1
  44. package/types/__new-tests__/hack.test.d.ts +0 -2
  45. package/types/__new-tests__/hack.test.d.ts.map +0 -1
  46. package/types/__new-tests__/omitProps.test.d.ts +0 -2
  47. package/types/__new-tests__/omitProps.test.d.ts.map +0 -1
  48. package/types/__new-tests__/passthroughProps.test.d.ts +0 -2
  49. package/types/__new-tests__/passthroughProps.test.d.ts.map +0 -1
  50. package/types/__new-tests__/pickProps.test.d.ts +0 -2
  51. package/types/__new-tests__/pickProps.test.d.ts.map +0 -1
  52. package/types/__new-tests__/safeCloneElement.test.d.ts +0 -2
  53. package/types/__new-tests__/safeCloneElement.test.d.ts.map +0 -1
@@ -1,113 +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 PropTypes from 'prop-types'
26
- import '@testing-library/jest-dom'
27
- import { omitProps } from '../omitProps'
28
-
29
- describe('omitProps', () => {
30
- it('should work with PropTypes', () => {
31
- const propTypes = {
32
- prop1: PropTypes.string.isRequired,
33
- prop2: PropTypes.number
34
- }
35
-
36
- const inputProps = {
37
- prop1: 'hello',
38
- prop2: 42,
39
- excessiveProp: 'excessiveValue'
40
- }
41
-
42
- const expectedResult = {
43
- excessiveProp: 'excessiveValue'
44
- }
45
-
46
- const actualResult = omitProps(inputProps, propTypes)
47
-
48
- expect(actualResult).toEqual(expectedResult)
49
- })
50
-
51
- it('should work with PropTypes and exclude the given keys', () => {
52
- const propTypes = {
53
- prop1: PropTypes.string.isRequired,
54
- prop2: PropTypes.number
55
- }
56
-
57
- const inputProps = {
58
- prop1: 'hello',
59
- prop2: 42,
60
- excessiveProp1: 'excessiveValue1',
61
- excessiveProp2: 'excessiveValue2'
62
- }
63
-
64
- const expectedResult = {
65
- excessiveProp2: 'excessiveValue2'
66
- }
67
-
68
- const actualResult = omitProps(inputProps, propTypes, ['excessiveProp1'])
69
-
70
- expect(actualResult).toEqual(expectedResult)
71
- })
72
-
73
- it('should work with an input of a list allowed prop names', () => {
74
- const allowedPropKeys = ['prop1', 'prop2']
75
-
76
- const inputProps = {
77
- prop1: 'hello',
78
- prop2: 42,
79
- excessiveProp1: 'excessiveValue1',
80
- excessiveProp2: 'excessiveValue2'
81
- }
82
-
83
- const expectedResult = {
84
- excessiveProp1: 'excessiveValue1',
85
- excessiveProp2: 'excessiveValue2'
86
- }
87
-
88
- const actualResult = omitProps(inputProps, allowedPropKeys)
89
-
90
- expect(actualResult).toEqual(expectedResult)
91
- })
92
-
93
- it('should work with an input of a list allowed prop names and exclude the given keys', () => {
94
- const allowedPropKeys = ['prop1', 'prop2']
95
-
96
- const inputProps = {
97
- prop1: 'hello',
98
- prop2: 42,
99
- excessiveProp1: 'excessiveValue1',
100
- excessiveProp2: 'excessiveValue2'
101
- }
102
-
103
- const expectedResult = {
104
- excessiveProp2: 'excessiveValue2'
105
- }
106
-
107
- const actualResult = omitProps(inputProps, allowedPropKeys, [
108
- 'excessiveProp1'
109
- ])
110
-
111
- expect(actualResult).toEqual(expectedResult)
112
- })
113
- })
@@ -1,100 +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 { passthroughProps } from '../passthroughProps'
27
-
28
- describe('passthroughProps', () => {
29
- it('should passthrough standard dom attributes', () => {
30
- const props = {
31
- id: 'myId',
32
- title: 'My title'
33
- }
34
- expect(Object.keys(passthroughProps(props)).length).toEqual(2)
35
- })
36
-
37
- it('should passthrough data attributes', () => {
38
- const props = {
39
- 'data-test': true
40
- }
41
- expect(Object.keys(passthroughProps(props)).length).toEqual(1)
42
- })
43
-
44
- it('should passthrough valid react props', () => {
45
- const props = {
46
- ref: () => {},
47
- innerHTML: '<span>hello world</span>'
48
- }
49
- expect(Object.keys(passthroughProps(props)).length).toEqual(2)
50
- })
51
-
52
- it('should passthrough props prefixed with "on"', () => {
53
- const props = {
54
- onClick: () => {},
55
- onCustomCallback: () => {},
56
- onChange: () => {}
57
- }
58
- expect(Object.keys(passthroughProps(props)).length).toEqual(3)
59
- })
60
-
61
- it('should omit invalid props', () => {
62
- const props = {
63
- myCustomProp: 'hello'
64
- }
65
- expect(Object.keys(passthroughProps(props)).length).toEqual(0)
66
- })
67
-
68
- it('should omit certain react props', () => {
69
- const props = {
70
- style: { color: 'blue' },
71
- className: 'myClass',
72
- children: 'hello world',
73
- theme: { themeVar: 'myColor' }
74
- }
75
- expect(Object.keys(passthroughProps(props)).length).toEqual(0)
76
- })
77
-
78
- it('should passthrough and omit correct props', () => {
79
- const props = {
80
- id: 'myId',
81
- title: 'My title',
82
- 'data-test': true,
83
- className: 'myClassName',
84
- children: 'hello world',
85
- style: { color: 'blue' },
86
- theme: { themeVar: 'myColor' },
87
- withSomething: false,
88
- onCustomCallback: null,
89
- onChange: null
90
- }
91
-
92
- expect(passthroughProps(props)).toEqual({
93
- id: 'myId',
94
- title: 'My title',
95
- 'data-test': true,
96
- onCustomCallback: null,
97
- onChange: null
98
- })
99
- })
100
- })
@@ -1,111 +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 PropTypes from 'prop-types'
26
- import '@testing-library/jest-dom'
27
- import { pickProps } from '../pickProps'
28
-
29
- describe('pickProps', () => {
30
- it('should work with propTypes', () => {
31
- const propTypes = {
32
- prop1: PropTypes.string.isRequired,
33
- prop2: PropTypes.number
34
- }
35
-
36
- const inputProps = {
37
- prop1: 'hello',
38
- prop2: 42,
39
- excessiveProp: 'excessiveValue'
40
- }
41
-
42
- const expectedResult = {
43
- prop1: 'hello',
44
- prop2: 42
45
- }
46
-
47
- const actualResult = pickProps(inputProps, propTypes)
48
-
49
- expect(actualResult).toEqual(expectedResult)
50
- })
51
-
52
- it('should add the `include` keys to the result with PropTypes', () => {
53
- const propTypes = {
54
- prop1: PropTypes.string.isRequired,
55
- prop2: PropTypes.number
56
- }
57
- const inputProps = {
58
- prop1: 'hello',
59
- prop2: 42,
60
- excessiveProp1: 'excessiveValue1',
61
- excessiveProp2: 'excessiveValue2'
62
- }
63
- const expectedResult = {
64
- prop1: 'hello',
65
- prop2: 42,
66
- excessiveProp2: 'excessiveValue2'
67
- }
68
-
69
- const actualResult = pickProps(inputProps, propTypes, ['excessiveProp2'])
70
-
71
- expect(actualResult).toEqual(expectedResult)
72
- })
73
-
74
- it('should work with an input of a list allowed prop names', () => {
75
- const allowedPropKeys = ['prop1', 'prop2']
76
- const inputProps = {
77
- prop1: 'hello',
78
- prop2: 42,
79
- excessiveProp1: 'excessiveValue1'
80
- }
81
- const expectedResult = {
82
- prop1: 'hello',
83
- prop2: 42
84
- }
85
-
86
- const actualResult = pickProps(inputProps, allowedPropKeys)
87
-
88
- expect(actualResult).toEqual(expectedResult)
89
- })
90
-
91
- it('should add the `include` keys to the result with a list allowed prop names', () => {
92
- const allowedPropKeys = ['prop1', 'prop2']
93
- const inputProps = {
94
- prop1: 'hello',
95
- prop2: 42,
96
- excessiveProp1: 'excessiveValue1',
97
- excessiveProp2: 'excessiveValue2'
98
- }
99
- const expectedResult = {
100
- prop1: 'hello',
101
- prop2: 42,
102
- excessiveProp2: 'excessiveValue2'
103
- }
104
-
105
- const actualResult = pickProps(inputProps, allowedPropKeys, [
106
- 'excessiveProp2'
107
- ])
108
-
109
- expect(actualResult).toEqual(expectedResult)
110
- })
111
- })
@@ -1,96 +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 { ReactElement, ReactNode } from 'react'
26
- import { vi } from 'vitest'
27
-
28
- import { createChainedFunction } from '@instructure/ui-utils'
29
- import { render, screen } from '@testing-library/react'
30
- import '@testing-library/jest-dom'
31
-
32
- import { safeCloneElement } from '../safeCloneElement'
33
-
34
- describe('safeCloneElement', () => {
35
- const SafeClone = function <P extends { style?: unknown }>({
36
- element,
37
- props,
38
- children
39
- }: {
40
- element: ReactElement<P>
41
- props: P
42
- children?: ReactNode[]
43
- }) {
44
- return safeCloneElement(element, props, children)
45
- }
46
-
47
- it('should preserve refs', () => {
48
- const origRef = vi.fn()
49
- const cloneRef = vi.fn()
50
-
51
- render(
52
- <SafeClone element={<div ref={origRef} />} props={{ ref: cloneRef }} />
53
- )
54
-
55
- expect(origRef).toHaveBeenCalled()
56
- expect(cloneRef).toHaveBeenCalled()
57
- })
58
-
59
- it('should preserve event handlers', () => {
60
- const onClickA = vi.fn()
61
- const onClickB = vi.fn()
62
-
63
- render(
64
- <SafeClone
65
- element={<button onClick={onClickA} />}
66
- props={{ onClick: onClickB }}
67
- />
68
- )
69
-
70
- const button = screen.getByRole('button')
71
- button.click()
72
-
73
- expect(onClickA).toHaveBeenCalled()
74
- expect(onClickB).toHaveBeenCalled()
75
- })
76
-
77
- it('should preserve already chained functions', () => {
78
- const onClickA = vi.fn()
79
- const onClickB = vi.fn()
80
- const onClickC = vi.fn()
81
-
82
- render(
83
- <SafeClone
84
- element={<button onClick={onClickA} />}
85
- props={{ onClick: createChainedFunction(onClickB, onClickC) }}
86
- />
87
- )
88
-
89
- const button = screen.getByRole('button')
90
- button.click()
91
-
92
- expect(onClickA).toHaveBeenCalled()
93
- expect(onClickB).toHaveBeenCalled()
94
- expect(onClickC).toHaveBeenCalled()
95
- })
96
- })
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=DeterministicIdContext.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeterministicIdContext.test.d.ts","sourceRoot":"","sources":["../../src/__new-tests__/DeterministicIdContext.test.tsx"],"names":[],"mappings":"AA2BA,OAAO,2BAA2B,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=callRenderProp.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"callRenderProp.test.d.ts","sourceRoot":"","sources":["../../src/__new-tests__/callRenderProp.test.tsx"],"names":[],"mappings":"AA4BA,OAAO,2BAA2B,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=deprecated.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deprecated.test.d.ts","sourceRoot":"","sources":["../../src/__new-tests__/deprecated.test.tsx"],"names":[],"mappings":"AA6BA,OAAO,2BAA2B,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=experimental.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"experimental.test.d.ts","sourceRoot":"","sources":["../../src/__new-tests__/experimental.test.tsx"],"names":[],"mappings":"AA6BA,OAAO,2BAA2B,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=getInteraction.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getInteraction.test.d.ts","sourceRoot":"","sources":["../../src/__new-tests__/getInteraction.test.tsx"],"names":[],"mappings":"AAwBA,OAAO,2BAA2B,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=hack.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hack.test.d.ts","sourceRoot":"","sources":["../../src/__new-tests__/hack.test.tsx"],"names":[],"mappings":"AA6BA,OAAO,2BAA2B,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=omitProps.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"omitProps.test.d.ts","sourceRoot":"","sources":["../../src/__new-tests__/omitProps.test.tsx"],"names":[],"mappings":"AAyBA,OAAO,2BAA2B,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=passthroughProps.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"passthroughProps.test.d.ts","sourceRoot":"","sources":["../../src/__new-tests__/passthroughProps.test.tsx"],"names":[],"mappings":"AAwBA,OAAO,2BAA2B,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=pickProps.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pickProps.test.d.ts","sourceRoot":"","sources":["../../src/__new-tests__/pickProps.test.tsx"],"names":[],"mappings":"AAyBA,OAAO,2BAA2B,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=safeCloneElement.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safeCloneElement.test.d.ts","sourceRoot":"","sources":["../../src/__new-tests__/safeCloneElement.test.tsx"],"names":[],"mappings":"AA6BA,OAAO,2BAA2B,CAAA"}