@instructure/ui-react-utils 8.53.3-snapshot-0 → 8.53.3-snapshot-6

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 (59) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/package.json +8 -9
  3. package/tsconfig.build.json +3 -0
  4. package/tsconfig.build.tsbuildinfo +1 -1
  5. package/es/__new-tests__/ComponentIdentifier.test.js +0 -77
  6. package/es/__new-tests__/DeterministicIdContext.test.js +0 -89
  7. package/es/__new-tests__/callRenderProp.test.js +0 -121
  8. package/es/__new-tests__/deprecated.test.js +0 -223
  9. package/es/__new-tests__/experimental.test.js +0 -94
  10. package/es/__new-tests__/getInteraction.test.js +0 -117
  11. package/es/__new-tests__/hack.test.js +0 -66
  12. package/es/__new-tests__/omitProps.test.js +0 -91
  13. package/es/__new-tests__/passthroughProps.test.js +0 -100
  14. package/es/__new-tests__/pickProps.test.js +0 -95
  15. package/es/__new-tests__/safeCloneElement.test.js +0 -86
  16. package/lib/__new-tests__/ComponentIdentifier.test.js +0 -80
  17. package/lib/__new-tests__/DeterministicIdContext.test.js +0 -91
  18. package/lib/__new-tests__/callRenderProp.test.js +0 -123
  19. package/lib/__new-tests__/deprecated.test.js +0 -227
  20. package/lib/__new-tests__/experimental.test.js +0 -98
  21. package/lib/__new-tests__/getInteraction.test.js +0 -119
  22. package/lib/__new-tests__/hack.test.js +0 -70
  23. package/lib/__new-tests__/omitProps.test.js +0 -94
  24. package/lib/__new-tests__/passthroughProps.test.js +0 -102
  25. package/lib/__new-tests__/pickProps.test.js +0 -98
  26. package/lib/__new-tests__/safeCloneElement.test.js +0 -89
  27. package/src/__new-tests__/ComponentIdentifier.test.tsx +0 -105
  28. package/src/__new-tests__/DeterministicIdContext.test.tsx +0 -126
  29. package/src/__new-tests__/callRenderProp.test.tsx +0 -136
  30. package/src/__new-tests__/deprecated.test.tsx +0 -357
  31. package/src/__new-tests__/experimental.test.tsx +0 -138
  32. package/src/__new-tests__/getInteraction.test.tsx +0 -119
  33. package/src/__new-tests__/hack.test.tsx +0 -90
  34. package/src/__new-tests__/omitProps.test.tsx +0 -113
  35. package/src/__new-tests__/passthroughProps.test.tsx +0 -100
  36. package/src/__new-tests__/pickProps.test.tsx +0 -111
  37. package/src/__new-tests__/safeCloneElement.test.tsx +0 -95
  38. package/types/__new-tests__/ComponentIdentifier.test.d.ts +0 -2
  39. package/types/__new-tests__/ComponentIdentifier.test.d.ts.map +0 -1
  40. package/types/__new-tests__/DeterministicIdContext.test.d.ts +0 -2
  41. package/types/__new-tests__/DeterministicIdContext.test.d.ts.map +0 -1
  42. package/types/__new-tests__/callRenderProp.test.d.ts +0 -2
  43. package/types/__new-tests__/callRenderProp.test.d.ts.map +0 -1
  44. package/types/__new-tests__/deprecated.test.d.ts +0 -2
  45. package/types/__new-tests__/deprecated.test.d.ts.map +0 -1
  46. package/types/__new-tests__/experimental.test.d.ts +0 -2
  47. package/types/__new-tests__/experimental.test.d.ts.map +0 -1
  48. package/types/__new-tests__/getInteraction.test.d.ts +0 -2
  49. package/types/__new-tests__/getInteraction.test.d.ts.map +0 -1
  50. package/types/__new-tests__/hack.test.d.ts +0 -2
  51. package/types/__new-tests__/hack.test.d.ts.map +0 -1
  52. package/types/__new-tests__/omitProps.test.d.ts +0 -2
  53. package/types/__new-tests__/omitProps.test.d.ts.map +0 -1
  54. package/types/__new-tests__/passthroughProps.test.d.ts +0 -2
  55. package/types/__new-tests__/passthroughProps.test.d.ts.map +0 -1
  56. package/types/__new-tests__/pickProps.test.d.ts +0 -2
  57. package/types/__new-tests__/pickProps.test.d.ts.map +0 -1
  58. package/types/__new-tests__/safeCloneElement.test.d.ts +0 -2
  59. package/types/__new-tests__/safeCloneElement.test.d.ts.map +0 -1
@@ -1,119 +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 { getInteraction, InteractionType } from '../getInteraction'
27
-
28
- describe('getInteraction', () => {
29
- it("should return 'enabled' when `interaction`, `disabled`, and `readOnly` are not provided", () => {
30
- const props = {
31
- foo: 'foo',
32
- bar: 'bar'
33
- }
34
-
35
- expect(getInteraction({ props })).toEqual('enabled')
36
- })
37
-
38
- it('should return `interaction` value when `interaction` is specified', () => {
39
- const props: { interaction: InteractionType } = {
40
- interaction: 'enabled'
41
- }
42
-
43
- expect(getInteraction({ props })).toEqual('enabled')
44
-
45
- props.interaction = 'disabled'
46
-
47
- expect(getInteraction({ props })).toEqual('disabled')
48
-
49
- props.interaction = 'readonly'
50
-
51
- expect(getInteraction({ props })).toEqual('readonly')
52
- })
53
-
54
- it('should give preference to interaction even when disabled and readonly are also specified', () => {
55
- const props: { interaction: InteractionType; [key: string]: any } = {
56
- interaction: 'enabled',
57
- disabled: true,
58
- readOnly: true
59
- }
60
-
61
- expect(getInteraction({ props })).toEqual('enabled')
62
-
63
- props.disabled = false
64
- props.interaction = 'disabled'
65
-
66
- expect(getInteraction({ props })).toEqual('disabled')
67
-
68
- props.readOnly = false
69
- props.interaction = 'readonly'
70
-
71
- expect(getInteraction({ props })).toEqual('readonly')
72
- })
73
-
74
- it("should return 'disabled' when `disabled` prop is set and `interaction` is not specified", () => {
75
- const props = {
76
- disabled: true
77
- }
78
-
79
- expect(getInteraction({ props })).toEqual('disabled')
80
- })
81
-
82
- it("should return 'disabled' when both `disabled` and `readonly` props are set and `interaction` is not specified", () => {
83
- const props = {
84
- disabled: true,
85
- readOnly: true
86
- }
87
-
88
- expect(getInteraction({ props })).toEqual('disabled')
89
- })
90
-
91
- it("should return 'readonly' when `readonly` prop is set and `interaction` and `disabled` are not specified", () => {
92
- const props = {
93
- disabled: true
94
- }
95
-
96
- expect(getInteraction({ props })).toEqual('disabled')
97
- })
98
-
99
- it('should not include `disabled` if it is not listed in the interactionTypes', () => {
100
- const props = {
101
- disabled: true,
102
- readOnly: true
103
- }
104
-
105
- expect(getInteraction({ props, interactionTypes: ['readonly'] })).toEqual(
106
- 'readonly'
107
- )
108
- })
109
-
110
- it('should not include `readonly` if it is not listed in the interactionTypes', () => {
111
- const props = {
112
- readOnly: true
113
- }
114
-
115
- expect(getInteraction({ props, interactionTypes: ['disabled'] })).toEqual(
116
- 'enabled'
117
- )
118
- })
119
- })
@@ -1,90 +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 React, { Component } from 'react'
26
- import PropTypes from 'prop-types'
27
-
28
- import { render } from '@testing-library/react'
29
- import '@testing-library/jest-dom'
30
-
31
- import { hack } from '../hack'
32
-
33
- type TestComponentProps = {
34
- bar: string
35
- qux: string
36
- }
37
- class TestComponent extends Component<TestComponentProps> {
38
- static propTypes = {
39
- bar: PropTypes.string,
40
- qux: PropTypes.string
41
- }
42
-
43
- static defaultProps = {
44
- bar: undefined,
45
- qux: 'Hello'
46
- }
47
-
48
- render() {
49
- return (
50
- <div>
51
- {this.props.qux} {this.props.bar}
52
- </div>
53
- )
54
- }
55
- }
56
-
57
- describe('@hack', () => {
58
- describe('hack props', () => {
59
- const HackComponent = hack(['bar'])(TestComponent)
60
-
61
- it('should warn when using an hack prop', () => {
62
- const consoleWarningSpy = jest
63
- .spyOn(console, 'warn')
64
- .mockImplementation(() => {})
65
- render(<HackComponent bar="Jane" />)
66
-
67
- const expectedWarningMessage =
68
- 'Warning: [TestComponent] The `bar` prop is a temporary hack and will be removed in a future release.'
69
-
70
- expect(consoleWarningSpy).toHaveBeenCalledWith(
71
- expect.stringContaining(expectedWarningMessage),
72
- expect.any(String)
73
- )
74
-
75
- consoleWarningSpy.mockRestore()
76
- })
77
-
78
- it('should not output a warning using a non-hack prop', () => {
79
- const consoleWarningSpy = jest
80
- .spyOn(console, 'warn')
81
- .mockImplementation(() => {})
82
-
83
- render(<HackComponent qux="Jane" />)
84
-
85
- expect(consoleWarningSpy).not.toHaveBeenCalled()
86
-
87
- consoleWarningSpy.mockRestore()
88
- })
89
- })
90
- })
@@ -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,95 +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 React, { ReactElement, ReactNode } from 'react'
26
-
27
- import { createChainedFunction } from '@instructure/ui-utils'
28
- import { render, screen } from '@testing-library/react'
29
- import '@testing-library/jest-dom'
30
-
31
- import { safeCloneElement } from '../safeCloneElement'
32
-
33
- describe('safeCloneElement', () => {
34
- const SafeClone = function <P extends { style?: unknown }>({
35
- element,
36
- props,
37
- children
38
- }: {
39
- element: ReactElement<P>
40
- props: P
41
- children?: ReactNode[]
42
- }) {
43
- return safeCloneElement(element, props, children)
44
- }
45
-
46
- it('should preserve refs', () => {
47
- const origRef = jest.fn()
48
- const cloneRef = jest.fn()
49
-
50
- render(
51
- <SafeClone element={<div ref={origRef} />} props={{ ref: cloneRef }} />
52
- )
53
-
54
- expect(origRef).toHaveBeenCalled()
55
- expect(cloneRef).toHaveBeenCalled()
56
- })
57
-
58
- it('should preserve event handlers', () => {
59
- const onClickA = jest.fn()
60
- const onClickB = jest.fn()
61
-
62
- render(
63
- <SafeClone
64
- element={<button onClick={onClickA} />}
65
- props={{ onClick: onClickB }}
66
- />
67
- )
68
-
69
- const button = screen.getByRole('button')
70
- button.click()
71
-
72
- expect(onClickA).toHaveBeenCalled()
73
- expect(onClickB).toHaveBeenCalled()
74
- })
75
-
76
- it('should preserve already chained functions', () => {
77
- const onClickA = jest.fn()
78
- const onClickB = jest.fn()
79
- const onClickC = jest.fn()
80
-
81
- render(
82
- <SafeClone
83
- element={<button onClick={onClickA} />}
84
- props={{ onClick: createChainedFunction(onClickB, onClickC) }}
85
- />
86
- )
87
-
88
- const button = screen.getByRole('button')
89
- button.click()
90
-
91
- expect(onClickA).toHaveBeenCalled()
92
- expect(onClickB).toHaveBeenCalled()
93
- expect(onClickC).toHaveBeenCalled()
94
- })
95
- })
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=ComponentIdentifier.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComponentIdentifier.test.d.ts","sourceRoot":"","sources":["../../src/__new-tests__/ComponentIdentifier.test.tsx"],"names":[],"mappings":"AA4BA,OAAO,2BAA2B,CAAA"}
@@ -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":"AA4BA,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":"AA4BA,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":"AA4BA,OAAO,2BAA2B,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=omitProps.test.d.ts.map