@procore/core-react 11.25.1 → 11.25.2

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 (204) hide show
  1. package/babel.config.js +1 -1
  2. package/dist/Avatar/Avatar.styles.js +5 -5
  3. package/dist/AvatarStack/AvatarStack.styles.js +7 -7
  4. package/dist/Badge/Badge.styles.js +2 -2
  5. package/dist/Banner/Banner.styles.js +10 -10
  6. package/dist/Box/Box.styles.js +1 -1
  7. package/dist/Breadcrumbs/Breadcrumbs.styles.js +4 -4
  8. package/dist/Button/Button.styles.js +5 -5
  9. package/dist/Calendar/Calendar.styles.js +8 -8
  10. package/dist/Card/Card.styles.js +1 -1
  11. package/dist/Checkbox/Checkbox.styles.js +6 -6
  12. package/dist/ContactItem/ContactItem.styles.js +5 -5
  13. package/dist/Content/Content.styles.js +2 -2
  14. package/dist/DateInput/DateInput.styles.js +6 -6
  15. package/dist/DetailPage/DetailPage.styles.js +7 -7
  16. package/dist/Dropdown/Dropdown.styles.js +3 -3
  17. package/dist/DropdownFlyout/DropdownFlyout.styles.js +4 -4
  18. package/dist/Dropzone/Dropzone.js +1 -1
  19. package/dist/Dropzone/Dropzone.styles.js +9 -9
  20. package/dist/EmptyState/EmptyState.styles.js +6 -6
  21. package/dist/Field/Field.styles.js +3 -3
  22. package/dist/FileList/FileList.styles.js +4 -4
  23. package/dist/FileSelect/FileExplorer/FileExplorer.styles.js +9 -9
  24. package/dist/FileSelect/FileExplorer/FileExplorerSidebar.styles.js +3 -3
  25. package/dist/FileSelect/FileSelect.styles.js +2 -2
  26. package/dist/FileSelect/FileSelectDropzone/FileSelectDropzone.styles.js +3 -3
  27. package/dist/FileSelect/FileTokenList/FileTokenList.styles.js +2 -2
  28. package/dist/FileSelect/GridSource/GridSource.styles.js +6 -6
  29. package/dist/FileSelect/LocalSource/LocalSource.styles.js +4 -4
  30. package/dist/FileSelect/SourceItem/SourceItem.styles.js +3 -3
  31. package/dist/FileSelect/ThumbnailList/ThumbnailList.styles.js +6 -6
  32. package/dist/FileSelect/TreeSource/TreeSource.styles.js +1 -1
  33. package/dist/FileToken/FileToken.styles.js +4 -4
  34. package/dist/FilterToken/FilterToken.styles.js +2 -2
  35. package/dist/FlexList/FlexList.styles.js +1 -1
  36. package/dist/Form/Form.styles.js +16 -16
  37. package/dist/Grid/Grid.styles.js +2 -2
  38. package/dist/GroupSelect/GroupSelect.styles.js +1 -1
  39. package/dist/Input/Input.styles.js +1 -1
  40. package/dist/Link/Link.styles.js +1 -1
  41. package/dist/ListPage/ListPage.styles.js +8 -8
  42. package/dist/Loader/Loader.styles.js +2 -2
  43. package/dist/MenuImperative/MenuImperative.styles.js +10 -10
  44. package/dist/Modal/Modal.styles.js +13 -13
  45. package/dist/MultiSelect/MultiSelect.styles.js +6 -6
  46. package/dist/NextMenu/NextMenu.styles.js +3 -3
  47. package/dist/Notation/Notation.js +1 -1
  48. package/dist/NumberInput/NumberInput.styles.js +7 -7
  49. package/dist/Overlay/OverlayArrow.styles.js +1 -1
  50. package/dist/PageLayout/PageLayout.styles.js +13 -13
  51. package/dist/Pagination/Pagination.styles.js +5 -5
  52. package/dist/Panel/Panel.styles.js +11 -11
  53. package/dist/Pill/Pill.styles.js +2 -2
  54. package/dist/PillSelect/PillSelect.styles.js +4 -4
  55. package/dist/Popover/Popover.styles.js +2 -2
  56. package/dist/Portal/Portal.styles.js +1 -1
  57. package/dist/ProgressBar/ProgressBar.styles.js +2 -2
  58. package/dist/RadioButton/RadioButton.styles.js +3 -3
  59. package/dist/Required/Required.styles.js +3 -3
  60. package/dist/Search/Search.styles.js +5 -5
  61. package/dist/Section/Section.styles.js +6 -6
  62. package/dist/SegmentedController/SegmentedController.styles.js +4 -4
  63. package/dist/Select/Select.styles.js +7 -7
  64. package/dist/Semantic/Semantic.d.ts +6 -1
  65. package/dist/Semantic/Semantic.js +7 -1
  66. package/dist/Semantic/Semantic.js.map +1 -1
  67. package/dist/Semantic/Semantic.styles.d.ts +14 -4
  68. package/dist/Semantic/Semantic.styles.js +20 -10
  69. package/dist/Semantic/Semantic.styles.js.map +1 -1
  70. package/dist/Semantic/index.d.ts +1 -1
  71. package/dist/Semantic/index.js +1 -1
  72. package/dist/Semantic/index.js.map +1 -1
  73. package/dist/Sidebar/Sidebar.styles.js +7 -7
  74. package/dist/Slider/Slider.styles.js +5 -5
  75. package/dist/Spinner/Spinner.styles.js +7 -7
  76. package/dist/SuperSelect/SuperSelect.presets.styles.js +1 -1
  77. package/dist/SuperSelect/SuperSelect.styles.js +37 -37
  78. package/dist/Switch/Switch.styles.js +4 -4
  79. package/dist/Table/Table.styles.js +28 -28
  80. package/dist/TableShelf/TableShelf.styles.js +5 -5
  81. package/dist/Tabs/Tabs.styles.js +8 -8
  82. package/dist/Tearsheet/Tearsheet.styles.js +5 -5
  83. package/dist/TextArea/TextArea.styles.js +1 -1
  84. package/dist/TextEditorOutput/TextEditorOutput.styles.js +1 -1
  85. package/dist/Thumbnail/Thumbnail.styles.js +17 -17
  86. package/dist/ThumbnailGrid/ThumbnailGrid.styles.js +7 -7
  87. package/dist/TieredSelect/TieredSelect.styles.js +9 -9
  88. package/dist/Tile/Tile.styles.js +8 -8
  89. package/dist/Title/Title.styles.js +7 -7
  90. package/dist/Toast/Toast.styles.js +3 -3
  91. package/dist/ToggleButton/ToggleButton.styles.js +1 -1
  92. package/dist/Token/Token.styles.js +3 -3
  93. package/dist/ToolHeader/ToolHeader.styles.js +6 -6
  94. package/dist/Tooltip/Tooltip.styles.js +2 -2
  95. package/dist/Tree/Tree.styles.js +9 -9
  96. package/dist/Typeahead/Typeahead.styles.js +3 -3
  97. package/dist/Typography/Typography.styles.js +1 -1
  98. package/dist/Typography/Typography.table.story.js +2 -2
  99. package/dist/_typedoc/Avatar/Avatar.types.json +20 -20
  100. package/dist/_typedoc/AvatarStack/AvatarStack.types.json +23 -23
  101. package/dist/_typedoc/Badge/Badge.types.json +6 -6
  102. package/dist/_typedoc/Banner/Banner.types.json +13 -13
  103. package/dist/_typedoc/Box/Box.types.json +68 -68
  104. package/dist/_typedoc/Breadcrumbs/Breadcrumbs.types.json +10 -10
  105. package/dist/_typedoc/Button/Button.types.json +11 -11
  106. package/dist/_typedoc/Calendar/Calendar.types.json +80 -80
  107. package/dist/_typedoc/Card/Card.types.json +6 -6
  108. package/dist/_typedoc/Checkbox/Checkbox.types.json +9 -9
  109. package/dist/_typedoc/ContactItem/ContactItem.types.json +9 -9
  110. package/dist/_typedoc/DateInput/DateInput.types.json +35 -35
  111. package/dist/_typedoc/DateSelect/DateSelect.types.json +13 -13
  112. package/dist/_typedoc/DetailPage/DetailPage.types.json +4 -4
  113. package/dist/_typedoc/Dropdown/Dropdown.types.json +37 -37
  114. package/dist/_typedoc/DropdownFlyout/DropdownFlyout.types.json +29 -29
  115. package/dist/_typedoc/Dropzone/Dropzone.types.json +41 -41
  116. package/dist/_typedoc/EmptyState/EmptyState.types.json +14 -14
  117. package/dist/_typedoc/FileList/FileList.types.json +9 -9
  118. package/dist/_typedoc/FileSelect/FileSelect.types.json +26 -26
  119. package/dist/_typedoc/FileSelect/GridSource/GridSource.types.json +20 -20
  120. package/dist/_typedoc/FileSelect/LocalSource/LocalSource.types.json +14 -14
  121. package/dist/_typedoc/FileSelect/TreeSource/TreeSource.types.json +9 -9
  122. package/dist/_typedoc/Flex/Flex.types.json +27 -27
  123. package/dist/_typedoc/FlexList/FlexList.types.json +30 -30
  124. package/dist/_typedoc/Form/Form.types.json +726 -726
  125. package/dist/_typedoc/Grid/Grid.types.json +8 -8
  126. package/dist/_typedoc/GroupSelect/GroupSelect.types.json +52 -52
  127. package/dist/_typedoc/Input/Input.types.json +2 -2
  128. package/dist/_typedoc/Link/Link.types.json +4 -4
  129. package/dist/_typedoc/ListPage/ListPage.types.json +13 -13
  130. package/dist/_typedoc/Menu/Menu.types.json +62 -62
  131. package/dist/_typedoc/MenuImperative/MenuImperative.types.json +74 -74
  132. package/dist/_typedoc/Modal/Modal.types.json +41 -41
  133. package/dist/_typedoc/MultiSelect/MultiSelect.types.json +31 -31
  134. package/dist/_typedoc/Notation/Notation.types.json +4 -4
  135. package/dist/_typedoc/NumberInput/NumberInput.types.json +38 -38
  136. package/dist/_typedoc/OverlayTrigger/OverlayTrigger.types.json +31 -31
  137. package/dist/_typedoc/PageLayout/PageLayout.types.json +22 -22
  138. package/dist/_typedoc/Pagination/Pagination.types.json +7 -7
  139. package/dist/_typedoc/Panel/Panel.types.json +27 -27
  140. package/dist/_typedoc/Pill/Pill.types.json +2 -2
  141. package/dist/_typedoc/PillSelect/PillSelect.types.json +47 -47
  142. package/dist/_typedoc/Popover/Popover.types.json +14 -14
  143. package/dist/_typedoc/ProgressBar/ProgressBar.types.json +6 -6
  144. package/dist/_typedoc/RadioButton/RadioButton.types.json +6 -6
  145. package/dist/_typedoc/Required/Required.types.json +5 -5
  146. package/dist/_typedoc/Search/Search.types.json +18 -18
  147. package/dist/_typedoc/Section/Section.types.json +14 -14
  148. package/dist/_typedoc/SegmentedController/SegmentedController.types.json +20 -20
  149. package/dist/_typedoc/Select/Select.types.json +57 -57
  150. package/dist/_typedoc/Slider/Slider.types.json +6 -6
  151. package/dist/_typedoc/Spinner/Spinner.types.json +9 -9
  152. package/dist/_typedoc/Switch/Switch.types.json +3 -3
  153. package/dist/_typedoc/Table/Table.types.json +97 -97
  154. package/dist/_typedoc/Tabs/Tabs.types.json +17 -17
  155. package/dist/_typedoc/Tearsheet/Tearsheet.types.json +16 -16
  156. package/dist/_typedoc/TextArea/TextArea.types.json +3 -3
  157. package/dist/_typedoc/TextEditor/TextEditor.types.json +9 -9
  158. package/dist/_typedoc/TextEditorOutput/TextEditorOutput.types.json +4 -4
  159. package/dist/_typedoc/Thumbnail/Thumbnail.types.json +19 -19
  160. package/dist/_typedoc/TieredDropdown/TieredDropdown.types.json +42 -42
  161. package/dist/_typedoc/TieredSelect/TieredSelect.types.json +28 -28
  162. package/dist/_typedoc/Tile/Tile.types.json +30 -30
  163. package/dist/_typedoc/Toast/Toast.types.json +4 -4
  164. package/dist/_typedoc/ToggleButton/ToggleButton.types.json +3 -3
  165. package/dist/_typedoc/Token/Token.types.json +4 -4
  166. package/dist/_typedoc/ToolHeader/ToolHeader.types.json +10 -10
  167. package/dist/_typedoc/Tooltip/Tooltip.types.json +13 -13
  168. package/dist/_typedoc/Tree/Tree.types.json +86 -86
  169. package/dist/_typedoc/Typeahead/Typeahead.types.json +2 -2
  170. package/dist/_typedoc/Typography/Typography.types.json +8 -8
  171. package/dist/_typedoc/_utils/types.json +3 -3
  172. package/dist/index.d.ts +1 -0
  173. package/dist/index.js +1 -0
  174. package/dist/index.js.map +1 -1
  175. package/package.json +2 -2
  176. package/tsconfig.prod.json +7 -1
  177. package/dist/FileSelect/SourceItem/SourceItem.test.js +0 -53
  178. package/dist/MultiSelect/MultiSelect.test.js +0 -250
  179. package/dist/OverlayTrigger/OverlayTrigger.test.js +0 -483
  180. package/dist/SuperSelect/SuperSelect.utils.test.js +0 -717
  181. package/dist/SuperSelect/useSuperSelect.test.js +0 -1284
  182. package/dist/_hooks/OverflowObserver/OverflowObserver.test.js +0 -110
  183. package/dist/_hooks/__tests__/Anchor.test.js +0 -109
  184. package/dist/_hooks/__tests__/BoundingRect.test.js +0 -85
  185. package/dist/_hooks/__tests__/Buffer.test.js +0 -76
  186. package/dist/_hooks/__tests__/DateTime.test.js +0 -136
  187. package/dist/_hooks/__tests__/DelayedCallback.test.js +0 -119
  188. package/dist/_hooks/__tests__/DelayedToggle.test.js +0 -50
  189. package/dist/_hooks/__tests__/Deprecation.test.js +0 -58
  190. package/dist/_hooks/__tests__/Event.test.js +0 -46
  191. package/dist/_hooks/__tests__/EventListener.test.js +0 -124
  192. package/dist/_hooks/__tests__/Hotkey.test.js +0 -18
  193. package/dist/_hooks/__tests__/InjectedScript.test.js +0 -80
  194. package/dist/_hooks/__tests__/ListNavigation.test.js +0 -101
  195. package/dist/_hooks/__tests__/TextEntry.test.js +0 -92
  196. package/dist/_hooks/__tests__/Timer.test.js +0 -60
  197. package/dist/_hooks/__tests__/Trigger.test.js +0 -52
  198. package/dist/_hooks/__tests__/Visibility.test.js +0 -86
  199. package/dist/_hooks/__tests__/ZIndex.test.js +0 -76
  200. package/dist/_utils/__tests__/CalendarHelpers.test.js +0 -64
  201. package/dist/_utils/__tests__/filename.test.js +0 -27
  202. package/dist/_utils/__tests__/getAnchorPosition.test.js +0 -250
  203. package/dist/_utils/__tests__/mergeRefs.test.js +0 -58
  204. package/dist/_utils/__tests__/slotify.test.js +0 -152
@@ -1,58 +0,0 @@
1
- import { renderHook } from '@testing-library/react-hooks'
2
-
3
- import { useDeprecation } from '../Deprecation'
4
-
5
- const oldThing = 'Boooo'
6
- const newThing = 'Yaaaay'
7
- const link = 'https://dwitter.net'
8
-
9
- /* eslint-disable no-console */
10
- describe('useDeprecation', () => {
11
- let spy
12
- beforeEach(() => {
13
- spy = jest.spyOn(console, 'warn').mockImplementation(() => {})
14
- })
15
-
16
- afterEach(() => {
17
- spy.mockRestore()
18
- })
19
-
20
- const checkIsWarningCalled = (times = 1) => {
21
- expect(spy).toBeCalledTimes(times)
22
-
23
- for (let i = 0; i < times; i++) {
24
- expect(console.warn.mock.calls[i][0]).toContain(
25
- `${oldThing} is deprecated, please use ${newThing}`
26
- )
27
- expect(console.warn.mock.calls[i][1]).toContain(`${link}`)
28
- }
29
- }
30
-
31
- it('should warn without passing "when"', () => {
32
- renderHook(() => useDeprecation({ oldThing, newThing, link }))
33
- checkIsWarningCalled()
34
- })
35
-
36
- it('should warn when "when" is truthy', () => {
37
- renderHook(() => useDeprecation({ oldThing, newThing, link, when: true }))
38
- renderHook(() => useDeprecation({ oldThing, newThing, link, when: 'prop' }))
39
- checkIsWarningCalled(2)
40
- })
41
-
42
- it('should warn when "when" is falsy(except undefined)', () => {
43
- renderHook(() => useDeprecation({ oldThing, newThing, link, when: 0 }))
44
- renderHook(() => useDeprecation({ oldThing, newThing, link, when: null }))
45
- renderHook(() => useDeprecation({ oldThing, newThing, link, when: false }))
46
- renderHook(() => useDeprecation({ oldThing, newThing, link, when: '' }))
47
- checkIsWarningCalled(4)
48
- })
49
-
50
- it('should not warn when "when" is undefined', () => {
51
- renderHook(() =>
52
- useDeprecation({ oldThing, newThing, link, when: undefined })
53
- )
54
-
55
- expect(spy).toBeCalledTimes(0)
56
- })
57
- })
58
- /* eslint-enable no-console */
@@ -1,46 +0,0 @@
1
- import {
2
- testContext,
3
- testHook,
4
- testRenderProp,
5
- } from '../../__tests__/helpers/state'
6
- import { Event, EventProvider, useEvent, useEventContext } from '../Event'
7
-
8
- const validateAPI = (api) => {
9
- expect(api.value).toEqual(null)
10
- }
11
-
12
- const apiTest = {
13
- test: 'api',
14
- config: {},
15
- callback: validateAPI,
16
- }
17
-
18
- jest.spyOn(global.console, 'warn').mockImplementation(() => {})
19
-
20
- afterAll(() => {
21
- jest.clearAllMocks()
22
- })
23
-
24
- describe('Event', () => {
25
- testHook(useEvent, [
26
- apiTest,
27
- {
28
- test: 'mutations',
29
- config: { initialValue: 'foo' },
30
- },
31
- ])
32
-
33
- testRenderProp(Event, 'event', [apiTest])
34
-
35
- testContext(EventProvider, useEventContext, [
36
- apiTest,
37
- {
38
- test: 'missing provider',
39
- config: {},
40
- injectProvider: false,
41
- callback: (context, { spy }) => {
42
- expect(context.value).toBe(null)
43
- },
44
- },
45
- ])
46
- })
@@ -1,124 +0,0 @@
1
- import { mount } from 'enzyme'
2
- import React from 'react'
3
-
4
- import { useEventListener } from '../EventListener'
5
-
6
- function noop() {}
7
-
8
- const mockScope = () => {
9
- const listeners = {}
10
-
11
- const scope = {
12
- addEventListener: jest.fn((event, cb) => {
13
- listeners[event] = cb
14
- }),
15
- removeEventListener: jest.fn((event, cb) => {
16
- listeners[event] = null
17
- }),
18
- }
19
-
20
- return { current: scope }
21
- }
22
-
23
- const mockWindowScope = () => {
24
- const listeners = {}
25
-
26
- const scope = {
27
- addEventListener: jest.fn((event, cb) => {
28
- listeners[event] = cb
29
- }),
30
- removeEventListener: jest.fn((event, cb) => {
31
- listeners[event] = null
32
- }),
33
- }
34
-
35
- return scope
36
- }
37
-
38
- const Enhanced = (props) => {
39
- useEventListener(props)
40
-
41
- return null
42
- }
43
-
44
- describe('useEventListener', () => {
45
- describe('scope changes', () => {
46
- const scopeA = mockScope()
47
- const scopeB = mockScope()
48
-
49
- mount(<Enhanced event="scroll" handler={noop} scope={scopeA} />).setProps({
50
- scope: scopeB,
51
- })
52
-
53
- it('adds and removes listeners to scope when scope changes', (done) => {
54
- setTimeout(() => {
55
- expect(scopeA.current.removeEventListener).toBeCalledTimes(1)
56
- expect(scopeB.current.addEventListener).toBeCalledTimes(1)
57
- done()
58
- }, 10)
59
- })
60
- })
61
-
62
- describe('scope types', () => {
63
- const scopeA = mockWindowScope()
64
-
65
- mount(<Enhanced event="scroll" handler={noop} scope={scopeA} />)
66
-
67
- it('adds listeners to custom window scope', (done) => {
68
- setTimeout(() => {
69
- expect(scopeA.addEventListener).toBeCalledTimes(1)
70
- done()
71
- }, 10)
72
- })
73
-
74
- it('adds listeners to ref scope', (done) => {
75
- const scopeB = mockScope()
76
-
77
- mount(<Enhanced event="scroll" handler={noop} scope={scopeB} />)
78
-
79
- setTimeout(() => {
80
- expect(scopeB.current.addEventListener).toBeCalledTimes(1)
81
- done()
82
- }, 10)
83
- })
84
-
85
- it('adds listeners to window when no scope is passed', () => {
86
- global.addEventListener = jest.fn()
87
- mount(<Enhanced event="scroll" handler={noop} />)
88
-
89
- expect(global.addEventListener).toHaveBeenCalled()
90
- })
91
- })
92
-
93
- describe('event type changes', () => {
94
- const scope = mockScope()
95
-
96
- mount(<Enhanced event="scroll" handler={noop} scope={scope} />).setProps({
97
- event: 'resize',
98
- })
99
-
100
- it('adds and removes listeners from scope when event changes', (done) => {
101
- setTimeout(() => {
102
- expect(scope.current.addEventListener).toBeCalledTimes(2)
103
- expect(scope.current.removeEventListener).toBeCalledTimes(1)
104
- done()
105
- }, 10)
106
- })
107
- })
108
-
109
- describe('handler changes', () => {
110
- const scope = mockScope()
111
-
112
- mount(<Enhanced event="scroll" handler={noop} scope={scope} />).setProps({
113
- handler: () => {},
114
- })
115
-
116
- it('keeps the same listener when handler changes', (done) => {
117
- setTimeout(() => {
118
- expect(scope.current.addEventListener).toBeCalledTimes(1)
119
- expect(scope.current.removeEventListener).toBeCalledTimes(0)
120
- done()
121
- }, 10)
122
- })
123
- })
124
- })
@@ -1,18 +0,0 @@
1
- import { fireEvent } from '@testing-library/react'
2
- import { act, renderHook } from '@testing-library/react-hooks'
3
-
4
- import { useHotkey } from '../Hotkey'
5
-
6
- describe('useHotkey', () => {
7
- it('binds key handlers', () => {
8
- const onSubmit = jest.fn()
9
-
10
- renderHook(() => useHotkey({ key: 'Enter', handler: onSubmit }))
11
-
12
- act(() => {
13
- fireEvent.keyDown(window, { key: 'Enter' })
14
- fireEvent.keyDown(window, { key: 'Enter' })
15
- expect(onSubmit).toHaveBeenCalledTimes(2)
16
- })
17
- })
18
- })
@@ -1,80 +0,0 @@
1
- import {
2
- testContext,
3
- testHook,
4
- testRenderProp,
5
- } from '../../__tests__/helpers/state'
6
- import {
7
- InjectedScript,
8
- InjectedScriptProvider,
9
- useInjectedScript,
10
- useInjectedScriptContext,
11
- } from '../InjectedScript'
12
-
13
- const validateAPI = (api) => {
14
- expect(api.isLoaded).toEqual(false)
15
- expect(api.setLoaded).toBeInstanceOf(Function)
16
- }
17
-
18
- const apiTest = {
19
- test: 'api',
20
- config: {
21
- id: 'foo',
22
- src: 'bar',
23
- },
24
- callback: validateAPI,
25
- }
26
-
27
- const configTest = {
28
- test: 'config',
29
- config: {
30
- id: 'foo',
31
- src: 'bar',
32
- },
33
- callback: ({ id, src }) => {
34
- expect(id).toEqual(id)
35
- expect(src).toEqual(src)
36
- },
37
- }
38
-
39
- beforeEach(() => {
40
- document.head.innerHTML = ''
41
- })
42
-
43
- describe('InjectedScript', () => {
44
- testHook(useInjectedScript, [
45
- apiTest,
46
- configTest,
47
- {
48
- test: 'mutations',
49
- config: {},
50
- mutations: [
51
- ['setLoaded', true, ['isLoaded', 'toBe', true]],
52
- ['setLoaded', false, ['isLoaded', 'toBe', false]],
53
- ],
54
- },
55
- ])
56
-
57
- testRenderProp(InjectedScript, 'injectedScript', [apiTest, configTest])
58
-
59
- testContext(InjectedScriptProvider, useInjectedScriptContext, [
60
- apiTest,
61
- configTest,
62
- {
63
- test: 'missing provider',
64
- config: {},
65
- injectProvider: false,
66
- callback: (context, { spy }) => {
67
- spy.mockImplementation(() => {})
68
-
69
- expect(context.isLoaded).toBe(false)
70
- context.setLoaded()
71
- expect(spy).toBeCalledTimes(1)
72
- expect(spy).toBeCalledWith(
73
- 'Could not call `setLoaded`, please wrap your component in a `<InjectedScriptProvider>`'
74
- )
75
-
76
- spy.mockRestore()
77
- },
78
- },
79
- ])
80
- })
@@ -1,101 +0,0 @@
1
- import {
2
- testContext,
3
- testHook,
4
- testRenderProp,
5
- } from '../../__tests__/helpers/state'
6
- import {
7
- ListNavigation,
8
- ListNavigationProvider,
9
- useListNavigation,
10
- useListNavigationContext,
11
- } from '../ListNavigation'
12
-
13
- const validateAPI = (api) => {
14
- expect(api.index).toEqual(0)
15
- expect(api.set).toBeInstanceOf(Function)
16
- expect(api.increment).toBeInstanceOf(Function)
17
- expect(api.decrement).toBeInstanceOf(Function)
18
- expect(api.clear).toBeInstanceOf(Function)
19
- }
20
-
21
- const apiTest = {
22
- test: 'api',
23
- config: {},
24
- callback: validateAPI,
25
- }
26
-
27
- const configTest = {
28
- test: 'config',
29
- config: { initialIndex: 3 },
30
- callback: ({ index }) => expect(index).toEqual(3),
31
- }
32
-
33
- const spy = jest.spyOn(global.console, 'warn')
34
- beforeEach(() => {
35
- spy.mockReset()
36
- })
37
-
38
- describe('ListNavigation', () => {
39
- testHook(useListNavigation, [
40
- apiTest,
41
- configTest,
42
- {
43
- test: 'mutations',
44
- config: { size: 5, initialIndex: -1 },
45
- mutations: [
46
- ['set', 3, ['index', 'toBe', 3]],
47
- ['increment', null, ['index', 'toBe', 4]],
48
- ['decrement', null, ['index', 'toBe', 3]],
49
- ['clear', null, ['index', 'toBe', 0]],
50
- ['set', 3, ['index', 'toBe', 3]],
51
- ['decrementBy', 2, ['index', 'toBe', 1]],
52
- ['incrementBy', 3, ['index', 'toBe', 4]],
53
- ['reset', null, ['index', 'toBe', 0]],
54
- ],
55
- },
56
- {
57
- test: 'is circular',
58
- config: { circular: true, initialIndex: 4, size: 5 },
59
- mutations: [
60
- ['increment', null, ['index', 'toBe', 0]],
61
- ['decrement', null, ['index', 'toBe', 4]],
62
- ],
63
- },
64
- {
65
- test: 'is not circular, does not increment past size',
66
- config: { circular: false, initialIndex: 5, size: 6 },
67
- mutations: [['increment', null, ['index', 'toBe', 5]]],
68
- },
69
- {
70
- test: 'is not circular, does not have a size, can decrement',
71
- config: { circular: false, initialIndex: 100, size: 200 },
72
- mutations: [['decrement', null, ['index', 'toBe', 99]]],
73
- },
74
- {
75
- test: 'is not circular, does not have a size, can increment',
76
- config: { circular: false, initialIndex: 100, size: 200 },
77
- mutations: [['increment', null, ['index', 'toBe', 101]]],
78
- },
79
- ])
80
-
81
- testRenderProp(ListNavigation, 'listNavigation', [apiTest, configTest])
82
-
83
- testContext(ListNavigationProvider, useListNavigationContext, [
84
- apiTest,
85
- configTest,
86
- {
87
- test: 'missing provider',
88
- config: {},
89
- injectProvider: false,
90
- callback: (context, { spy }) => {
91
- expect(context.index).toBe(-1)
92
- context.set()
93
- context.increment()
94
- context.decrement()
95
- context.clear()
96
- context.reset()
97
- expect(spy).toBeCalledTimes(5)
98
- },
99
- },
100
- ])
101
- })
@@ -1,92 +0,0 @@
1
- import {
2
- testContext,
3
- testHook,
4
- testRenderProp,
5
- } from '../../__tests__/helpers/state'
6
- import {
7
- TextEntry,
8
- TextEntryProvider,
9
- useTextEntry,
10
- useTextEntryContext,
11
- } from '../TextEntry'
12
-
13
- const validateAPI = (api) => {
14
- expect(api.value).toEqual('')
15
- expect(api.empty).toEqual(true)
16
- expect(api.onChange).toBeInstanceOf(Function)
17
- expect(api.clear).toBeInstanceOf(Function)
18
- expect(api.reset).toBeInstanceOf(Function)
19
- }
20
-
21
- const apiTest = {
22
- test: 'api',
23
- config: {},
24
- callback: validateAPI,
25
- }
26
-
27
- const configTest = {
28
- test: 'config',
29
- config: { initialValue: 'foo', handler: jest.fn() },
30
- callback: ({ value }) => expect(value).toEqual('foo'),
31
- }
32
-
33
- const onChangeTest = () => {
34
- const onChange = jest.fn()
35
-
36
- return {
37
- test: 'handler',
38
- config: { onChange },
39
- callback: ({ reset }) => {
40
- reset()
41
- expect(onChange).toBeCalled()
42
- },
43
- }
44
- }
45
-
46
- describe('TextEntry', () => {
47
- testHook(useTextEntry, [
48
- apiTest,
49
- configTest,
50
- onChangeTest(),
51
- {
52
- test: 'mutations',
53
- config: { initialValue: 'foo' },
54
- mutations: [
55
- ['clear', null, ['value', 'toBe', '']],
56
- ['reset', null, ['value', 'toBe', 'foo']],
57
- ['reset', null, ['empty', 'toBe', false]],
58
- ],
59
- },
60
- ])
61
-
62
- testRenderProp(TextEntry, 'textEntry', [apiTest, configTest])
63
-
64
- testContext(TextEntryProvider, useTextEntryContext, [
65
- apiTest,
66
- configTest,
67
- {
68
- test: 'missing provider',
69
- config: {},
70
- injectProvider: false,
71
- callback: (context, { spy }) => {
72
- spy.mockImplementation(() => {})
73
-
74
- context.clear()
75
- context.reset()
76
- expect(spy).toBeCalledTimes(2)
77
- expect(spy).toHaveBeenNthCalledWith(
78
- 1,
79
- 'Could not call `clear`, please wrap your component in a `<TextEntryProvider>`'
80
- )
81
- expect(spy).toHaveBeenNthCalledWith(
82
- 2,
83
- 'Could not call `reset`, please wrap your component in a `<TextEntryProvider>`'
84
- )
85
- expect(context.value).toBe('')
86
- expect(context.empty).toBe(true)
87
-
88
- spy.mockRestore()
89
- },
90
- },
91
- ])
92
- })
@@ -1,60 +0,0 @@
1
- import { mount } from 'enzyme'
2
- import React from 'react'
3
- import {
4
- Component,
5
- getProps,
6
- testContext,
7
- testHook,
8
- testRenderProp,
9
- } from '../../__tests__/helpers/state'
10
- import { Timer, TimerProvider, useTimer, useTimerContext } from '../Timer'
11
-
12
- const validateAPI = (api) => {
13
- expect(api.setTimer).toBeInstanceOf(Function)
14
- }
15
-
16
- const apiTest = {
17
- test: 'api',
18
- config: {},
19
- callback: validateAPI,
20
- }
21
-
22
- describe('Timer', () => {
23
- it('calls the provided function after the given time', (done) => {
24
- const Enhanced = () => <Component {...useTimer()} />
25
- const dom = mount(<Enhanced />)
26
- const props = getProps(Component, dom)()
27
- const spy = jest.fn()
28
- props.setTimer(spy, 1000)
29
- expect(spy).toBeCalledTimes(0)
30
- setTimeout(() => {
31
- expect(spy).toBeCalledTimes(1)
32
- done()
33
- }, 1500)
34
- })
35
-
36
- testHook(useTimer, [apiTest])
37
-
38
- testRenderProp(Timer, 'timer', [apiTest])
39
-
40
- testContext(TimerProvider, useTimerContext, [
41
- apiTest,
42
- {
43
- test: 'missing provider',
44
- config: {},
45
- injectProvider: false,
46
- callback: (context, { spy }) => {
47
- spy.mockImplementation(() => {})
48
-
49
- expect(context.timerId).toBe(null)
50
- context.setTimer()
51
- expect(spy).toBeCalledTimes(1)
52
- expect(spy).toBeCalledWith(
53
- 'Could not call `setTimer`, please wrap your component in a `<TimerProvider>`'
54
- )
55
-
56
- spy.mockRestore()
57
- },
58
- },
59
- ])
60
- })
@@ -1,52 +0,0 @@
1
- import React from 'react'
2
- import {
3
- testContext,
4
- testHook,
5
- testRenderProp,
6
- } from '../../__tests__/helpers/state'
7
- import {
8
- initTrigger,
9
- Trigger,
10
- TriggerProvider,
11
- useTrigger,
12
- useTriggerContext,
13
- } from '../Trigger'
14
-
15
- const mockEnable = () => {}
16
- const mockDisable = () => {}
17
-
18
- const validateAPI = (api) => {
19
- expect(api.isVisible).toBe(false)
20
- expect(api.enable).toBeInstanceOf(Function)
21
- expect(api.disable).toBeInstanceOf(Function)
22
- expect(api.toggle).toBeInstanceOf(Function)
23
- }
24
-
25
- const apiTest = {
26
- test: 'api',
27
- config: {
28
- scope: React.createRef(),
29
- enable: mockEnable,
30
- disable: mockDisable,
31
- },
32
- callback: validateAPI,
33
- }
34
-
35
- describe('Trigger', () => {
36
- testHook(useTrigger, [apiTest])
37
-
38
- testRenderProp(Trigger, 'trigger', [apiTest])
39
-
40
- testContext(TriggerProvider, useTriggerContext, [
41
- apiTest,
42
- ,
43
- {
44
- test: 'missing provider',
45
- config: {},
46
- injectProvider: false,
47
- callback: (context) => {
48
- expect(context).toEqual(initTrigger)
49
- },
50
- },
51
- ])
52
- })