@mui/internal-test-utils 2.0.15 → 2.0.16

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 (212) hide show
  1. package/{src/chai.types.ts → chai.types.d.ts} +7 -40
  2. package/chai.types.js +5 -0
  3. package/chaiPlugin.d.ts +4 -0
  4. package/chaiPlugin.js +287 -0
  5. package/{build/components.d.ts → components.d.ts} +18 -19
  6. package/components.js +64 -0
  7. package/createDOM.d.ts +2 -0
  8. package/{src/createDOM.js → createDOM.js} +17 -35
  9. package/createDescribe.d.ts +7 -0
  10. package/createDescribe.js +26 -0
  11. package/createRenderer.d.ts +214 -0
  12. package/createRenderer.js +428 -0
  13. package/createRenderer.test.d.ts +1 -0
  14. package/describeConformance.d.ts +200 -0
  15. package/describeConformance.js +1038 -0
  16. package/env.d.ts +1 -0
  17. package/env.js +11 -0
  18. package/esm/chai.types.d.ts +74 -0
  19. package/esm/chai.types.js +3 -0
  20. package/esm/chaiPlugin.d.ts +4 -0
  21. package/esm/chaiPlugin.js +281 -0
  22. package/esm/components.d.ts +35 -0
  23. package/esm/components.js +56 -0
  24. package/esm/createDOM.d.ts +2 -0
  25. package/esm/createDOM.js +47 -0
  26. package/esm/createDescribe.d.ts +7 -0
  27. package/esm/createDescribe.js +19 -0
  28. package/esm/createRenderer.d.ts +214 -0
  29. package/esm/createRenderer.js +390 -0
  30. package/esm/createRenderer.test.d.ts +1 -0
  31. package/esm/describeConformance.d.ts +200 -0
  32. package/esm/describeConformance.js +1024 -0
  33. package/esm/env.d.ts +1 -0
  34. package/esm/env.js +5 -0
  35. package/{build → esm}/fireDiscreteEvent.d.ts +1 -2
  36. package/{src/fireDiscreteEvent.ts → esm/fireDiscreteEvent.js} +10 -18
  37. package/esm/flushMicrotasks.d.ts +1 -0
  38. package/{src/flushMicrotasks.ts → esm/flushMicrotasks.js} +2 -3
  39. package/{build → esm}/focusVisible.d.ts +1 -2
  40. package/{src/focusVisible.ts → esm/focusVisible.js} +10 -9
  41. package/esm/index.d.ts +18 -0
  42. package/esm/index.js +27 -0
  43. package/esm/init.d.ts +1 -0
  44. package/{src → esm}/init.js +4 -2
  45. package/esm/initMatchers.d.ts +1 -0
  46. package/esm/initMatchers.js +6 -0
  47. package/esm/initMatchers.test.d.ts +1 -0
  48. package/esm/initPlaywrightMatchers.d.ts +24 -0
  49. package/esm/initPlaywrightMatchers.js +40 -0
  50. package/esm/package.json +1 -0
  51. package/esm/reactMajor.d.ts +2 -0
  52. package/esm/reactMajor.js +2 -0
  53. package/esm/setup.d.ts +1 -0
  54. package/{src → esm}/setup.js +2 -4
  55. package/esm/setupVitest.d.ts +1 -0
  56. package/esm/setupVitest.js +28 -0
  57. package/esm/setupVitestBrowser.d.ts +1 -0
  58. package/esm/setupVitestBrowser.js +30 -0
  59. package/fireDiscreteEvent.d.ts +6 -0
  60. package/fireDiscreteEvent.js +79 -0
  61. package/flushMicrotasks.d.ts +1 -0
  62. package/flushMicrotasks.js +10 -0
  63. package/focusVisible.d.ts +7 -0
  64. package/focusVisible.js +44 -0
  65. package/index.d.ts +18 -0
  66. package/index.js +139 -0
  67. package/init.d.ts +1 -0
  68. package/init.js +15 -0
  69. package/initMatchers.d.ts +1 -0
  70. package/initMatchers.js +10 -0
  71. package/initMatchers.test.d.ts +1 -0
  72. package/initPlaywrightMatchers.d.ts +24 -0
  73. package/initPlaywrightMatchers.js +42 -0
  74. package/package.json +89 -46
  75. package/reactMajor.d.ts +2 -0
  76. package/reactMajor.js +9 -0
  77. package/setup.d.ts +1 -0
  78. package/setup.js +10 -0
  79. package/setupVitest.d.ts +1 -0
  80. package/setupVitest.js +32 -0
  81. package/setupVitestBrowser.d.ts +1 -0
  82. package/setupVitestBrowser.js +34 -0
  83. package/build/.tsbuildinfo +0 -1
  84. package/build/KarmaReporterReactProfiler.d.ts +0 -51
  85. package/build/KarmaReporterReactProfiler.d.ts.map +0 -1
  86. package/build/KarmaReporterReactProfiler.js +0 -66
  87. package/build/KarmaReporterReactProfiler.js.map +0 -1
  88. package/build/chai.types.d.ts +0 -75
  89. package/build/chai.types.d.ts.map +0 -1
  90. package/build/chai.types.js +0 -3
  91. package/build/chai.types.js.map +0 -1
  92. package/build/chaiPlugin.d.ts +0 -5
  93. package/build/chaiPlugin.d.ts.map +0 -1
  94. package/build/chaiPlugin.js +0 -416
  95. package/build/chaiPlugin.js.map +0 -1
  96. package/build/components.d.ts.map +0 -1
  97. package/build/components.js +0 -88
  98. package/build/components.js.map +0 -1
  99. package/build/createDOM.d.ts +0 -3
  100. package/build/createDOM.d.ts.map +0 -1
  101. package/build/createDOM.js +0 -60
  102. package/build/createDOM.js.map +0 -1
  103. package/build/createDescribe.d.ts +0 -8
  104. package/build/createDescribe.d.ts.map +0 -1
  105. package/build/createDescribe.js +0 -22
  106. package/build/createDescribe.js.map +0 -1
  107. package/build/createRenderer.d.ts +0 -215
  108. package/build/createRenderer.d.ts.map +0 -1
  109. package/build/createRenderer.js +0 -564
  110. package/build/createRenderer.js.map +0 -1
  111. package/build/createRenderer.test.d.ts +0 -2
  112. package/build/createRenderer.test.d.ts.map +0 -1
  113. package/build/createRenderer.test.js +0 -58
  114. package/build/createRenderer.test.js.map +0 -1
  115. package/build/describeConformance.d.ts +0 -201
  116. package/build/describeConformance.d.ts.map +0 -1
  117. package/build/describeConformance.js +0 -859
  118. package/build/describeConformance.js.map +0 -1
  119. package/build/describeSkipIf.d.ts +0 -4
  120. package/build/describeSkipIf.d.ts.map +0 -1
  121. package/build/describeSkipIf.js +0 -10
  122. package/build/describeSkipIf.js.map +0 -1
  123. package/build/fireDiscreteEvent.d.ts.map +0 -1
  124. package/build/fireDiscreteEvent.js +0 -77
  125. package/build/fireDiscreteEvent.js.map +0 -1
  126. package/build/flushMicrotasks.d.ts +0 -2
  127. package/build/flushMicrotasks.d.ts.map +0 -1
  128. package/build/flushMicrotasks.js +0 -8
  129. package/build/flushMicrotasks.js.map +0 -1
  130. package/build/focusVisible.d.ts.map +0 -1
  131. package/build/focusVisible.js +0 -38
  132. package/build/focusVisible.js.map +0 -1
  133. package/build/index.d.ts +0 -18
  134. package/build/index.d.ts.map +0 -1
  135. package/build/index.js +0 -68
  136. package/build/index.js.map +0 -1
  137. package/build/init.d.ts +0 -2
  138. package/build/init.d.ts.map +0 -1
  139. package/build/init.js +0 -46
  140. package/build/init.js.map +0 -1
  141. package/build/initMatchers.d.ts +0 -2
  142. package/build/initMatchers.d.ts.map +0 -1
  143. package/build/initMatchers.js +0 -45
  144. package/build/initMatchers.js.map +0 -1
  145. package/build/initMatchers.test.d.ts +0 -2
  146. package/build/initMatchers.test.d.ts.map +0 -1
  147. package/build/initMatchers.test.js +0 -101
  148. package/build/initMatchers.test.js.map +0 -1
  149. package/build/initPlaywrightMatchers.d.ts +0 -25
  150. package/build/initPlaywrightMatchers.d.ts.map +0 -1
  151. package/build/initPlaywrightMatchers.js +0 -73
  152. package/build/initPlaywrightMatchers.js.map +0 -1
  153. package/build/mochaHooks.d.ts +0 -24
  154. package/build/mochaHooks.d.ts.map +0 -1
  155. package/build/mochaHooks.js +0 -165
  156. package/build/mochaHooks.js.map +0 -1
  157. package/build/mochaHooks.test.d.ts +0 -2
  158. package/build/mochaHooks.test.d.ts.map +0 -1
  159. package/build/mochaHooks.test.js +0 -128
  160. package/build/mochaHooks.test.js.map +0 -1
  161. package/build/reactMajor.d.ts +0 -3
  162. package/build/reactMajor.d.ts.map +0 -1
  163. package/build/reactMajor.js +0 -38
  164. package/build/reactMajor.js.map +0 -1
  165. package/build/setup.d.ts +0 -2
  166. package/build/setup.d.ts.map +0 -1
  167. package/build/setup.js +0 -10
  168. package/build/setup.js.map +0 -1
  169. package/build/setupBabel.d.ts +0 -2
  170. package/build/setupBabel.d.ts.map +0 -1
  171. package/build/setupBabel.js +0 -5
  172. package/build/setupBabel.js.map +0 -1
  173. package/build/setupBabelPlaywright.d.ts +0 -2
  174. package/build/setupBabelPlaywright.d.ts.map +0 -1
  175. package/build/setupBabelPlaywright.js +0 -14
  176. package/build/setupBabelPlaywright.js.map +0 -1
  177. package/build/setupJSDOM.d.ts +0 -7
  178. package/build/setupJSDOM.d.ts.map +0 -1
  179. package/build/setupJSDOM.js +0 -17
  180. package/build/setupJSDOM.js.map +0 -1
  181. package/build/setupKarma.d.ts +0 -2
  182. package/build/setupKarma.d.ts.map +0 -1
  183. package/build/setupKarma.js +0 -56
  184. package/build/setupKarma.js.map +0 -1
  185. package/build/setupVitest.d.ts +0 -2
  186. package/build/setupVitest.d.ts.map +0 -1
  187. package/build/setupVitest.js +0 -131
  188. package/build/setupVitest.js.map +0 -1
  189. package/src/KarmaReporterReactProfiler.js +0 -82
  190. package/src/chai-augmentation.d.ts +0 -8
  191. package/src/chaiPlugin.ts +0 -515
  192. package/src/components.tsx +0 -61
  193. package/src/createDOM.d.ts +0 -9
  194. package/src/createDescribe.ts +0 -31
  195. package/src/createRenderer.test.js +0 -31
  196. package/src/createRenderer.tsx +0 -808
  197. package/src/describeConformance.tsx +0 -1257
  198. package/src/describeSkipIf.tsx +0 -11
  199. package/src/index.ts +0 -25
  200. package/src/initMatchers.test.js +0 -124
  201. package/src/initMatchers.ts +0 -7
  202. package/src/initPlaywrightMatchers.ts +0 -101
  203. package/src/mochaHooks.js +0 -200
  204. package/src/mochaHooks.test.js +0 -116
  205. package/src/reactMajor.ts +0 -3
  206. package/src/setupBabel.js +0 -3
  207. package/src/setupBabelPlaywright.js +0 -13
  208. package/src/setupJSDOM.js +0 -20
  209. package/src/setupKarma.js +0 -65
  210. package/src/setupVitest.ts +0 -117
  211. package/tsconfig.build.json +0 -16
  212. package/tsconfig.json +0 -17
@@ -0,0 +1,214 @@
1
+ import { queries, RenderResult, fireEvent as rtlFireEvent, Screen, RenderOptions as TestingLibraryRenderOptions } from '@testing-library/react/pure';
2
+ import { userEvent } from '@testing-library/user-event';
3
+ import * as React from 'react';
4
+ import { useFakeTimers } from 'sinon';
5
+ declare function queryAllDescriptionsOf(baseElement: HTMLElement, element: Element): HTMLElement[];
6
+ declare const customQueries: {
7
+ queryDescriptionOf: import("@testing-library/react/pure").QueryBy<[Element]>;
8
+ queryAllDescriptionsOf: typeof queryAllDescriptionsOf;
9
+ getDescriptionOf: import("@testing-library/react/pure").GetBy<[Element]>;
10
+ getAllDescriptionsOf: import("@testing-library/react/pure").GetAllBy<[Element]>;
11
+ findDescriptionOf: import("@testing-library/react/pure").FindBy<[Element]>;
12
+ findAllDescriptionsOf: import("@testing-library/react/pure").FindAllBy<[Element]>;
13
+ };
14
+ interface RenderConfiguration extends Pick<TestingLibraryRenderOptions, 'reactStrictMode'> {
15
+ /**
16
+ * https://testing-library.com/docs/react-testing-library/api#container
17
+ */
18
+ container?: HTMLElement;
19
+ /**
20
+ * if true does not cleanup before mount
21
+ */
22
+ disableUnmount?: boolean;
23
+ /**
24
+ * wrap in React.StrictMode?
25
+ */
26
+ strict?: boolean;
27
+ /**
28
+ * Set to `true` if the test fails due to [Strict Effects](https://github.com/reactwg/react-18/discussions/19).
29
+ */
30
+ strictEffects?: boolean;
31
+ wrapper: React.JSXElementConstructor<{
32
+ children?: React.ReactNode;
33
+ }>;
34
+ }
35
+ export type RenderOptions = Omit<Partial<RenderConfiguration>, 'reactStrictMode'>;
36
+ export interface MuiRenderResult extends RenderResult<typeof queries & typeof customQueries> {
37
+ user: ReturnType<typeof userEvent.setup>;
38
+ forceUpdate(): void;
39
+ /**
40
+ * convenience helper. Better than repeating all props.
41
+ */
42
+ setProps(props: object): void;
43
+ }
44
+ export interface MuiRenderToStringResult {
45
+ container: HTMLElement;
46
+ hydrate(): MuiRenderResult;
47
+ }
48
+ interface DataAttributes {
49
+ [key: `data-${string}`]: string;
50
+ }
51
+ export interface Clock {
52
+ /**
53
+ * Runs all timers until there are no more remaining.
54
+ * WARNING: This may cause an infinite loop if a timeout constantly schedules another timeout.
55
+ * Prefer to to run only pending timers with `runToLast` and unmount your component directly.
56
+ */
57
+ runAll(): void;
58
+ /**
59
+ * Runs only the currently pending timers.
60
+ */
61
+ runToLast(): void;
62
+ /**
63
+ * Tick the clock ahead `timeoutMS` milliseconds.
64
+ * @param timeoutMS
65
+ */
66
+ tick(timeoutMS: number): void;
67
+ /**
68
+ * Returns true if we're running with "real" i.e. native timers.
69
+ */
70
+ isReal(): boolean;
71
+ /**
72
+ * Runs the current test suite (i.e. `describe` block) with fake timers.
73
+ */
74
+ withFakeTimers(): void;
75
+ /**
76
+ * Restore the real timer
77
+ */
78
+ restore(): void;
79
+ }
80
+ export type ClockConfig = undefined | number | Date;
81
+ declare function createClock(defaultMode: 'fake' | 'real', config: ClockConfig, options: Exclude<Parameters<typeof useFakeTimers>[0], number | Date>): Clock;
82
+ export interface Renderer {
83
+ clock: Clock;
84
+ render(element: React.ReactElement<DataAttributes>, options?: RenderOptions): MuiRenderResult;
85
+ renderToString(element: React.ReactElement<DataAttributes>, options?: RenderOptions): MuiRenderToStringResult;
86
+ }
87
+ export interface CreateRendererOptions extends Pick<RenderOptions, 'strict' | 'strictEffects'> {
88
+ /**
89
+ * @default 'real'
90
+ */
91
+ clock?: 'fake' | 'real';
92
+ clockConfig?: ClockConfig;
93
+ clockOptions?: Parameters<typeof createClock>[2];
94
+ }
95
+ export declare function createRenderer(globalOptions?: CreateRendererOptions): Renderer;
96
+ declare const fireEvent: typeof rtlFireEvent;
97
+ export declare function fireTouchChangedEvent(target: Element, type: 'touchstart' | 'touchmove' | 'touchend', options: {
98
+ changedTouches: Array<Pick<TouchInit, 'clientX' | 'clientY'>>;
99
+ }): void;
100
+ declare function act<T>(callback: () => T | Promise<T>): Promise<T>;
101
+ declare function act(callback: () => void): void;
102
+ declare const bodyBoundQueries: {
103
+ getByLabelText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined): ReturnType<queries.GetByText<T>>;
104
+ getAllByLabelText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined): ReturnType<queries.AllByText<T>>;
105
+ queryByLabelText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined): ReturnType<queries.QueryByText<T>>;
106
+ queryAllByLabelText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined): ReturnType<queries.AllByText<T>>;
107
+ findByLabelText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindByText<T>>;
108
+ findAllByLabelText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindAllByText<T>>;
109
+ getByPlaceholderText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.GetByBoundAttribute<T>>;
110
+ getAllByPlaceholderText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.AllByBoundAttribute<T>>;
111
+ queryByPlaceholderText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.QueryByBoundAttribute<T>>;
112
+ queryAllByPlaceholderText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.AllByBoundAttribute<T>>;
113
+ findByPlaceholderText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindByBoundAttribute<T>>;
114
+ findAllByPlaceholderText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindAllByBoundAttribute<T>>;
115
+ getByText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined): ReturnType<queries.GetByText<T>>;
116
+ getAllByText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined): ReturnType<queries.AllByText<T>>;
117
+ queryByText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined): ReturnType<queries.QueryByText<T>>;
118
+ queryAllByText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined): ReturnType<queries.AllByText<T>>;
119
+ findByText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindByText<T>>;
120
+ findAllByText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindAllByText<T>>;
121
+ getByAltText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.GetByBoundAttribute<T>>;
122
+ getAllByAltText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.AllByBoundAttribute<T>>;
123
+ queryByAltText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.QueryByBoundAttribute<T>>;
124
+ queryAllByAltText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.AllByBoundAttribute<T>>;
125
+ findByAltText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindByBoundAttribute<T>>;
126
+ findAllByAltText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindAllByBoundAttribute<T>>;
127
+ getByTitle<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.GetByBoundAttribute<T>>;
128
+ getAllByTitle<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.AllByBoundAttribute<T>>;
129
+ queryByTitle<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.QueryByBoundAttribute<T>>;
130
+ queryAllByTitle<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.AllByBoundAttribute<T>>;
131
+ findByTitle<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindByBoundAttribute<T>>;
132
+ findAllByTitle<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindAllByBoundAttribute<T>>;
133
+ getByDisplayValue<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.GetByBoundAttribute<T>>;
134
+ getAllByDisplayValue<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.AllByBoundAttribute<T>>;
135
+ queryByDisplayValue<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.QueryByBoundAttribute<T>>;
136
+ queryAllByDisplayValue<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.AllByBoundAttribute<T>>;
137
+ findByDisplayValue<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindByBoundAttribute<T>>;
138
+ findAllByDisplayValue<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindAllByBoundAttribute<T>>;
139
+ getByRole<T extends HTMLElement = HTMLElement>(role: import("@testing-library/react/pure").ByRoleMatcher, options?: queries.ByRoleOptions | undefined): ReturnType<queries.GetByRole<T>>;
140
+ getAllByRole<T extends HTMLElement = HTMLElement>(role: import("@testing-library/react/pure").ByRoleMatcher, options?: queries.ByRoleOptions | undefined): ReturnType<queries.AllByRole<T>>;
141
+ queryByRole<T extends HTMLElement = HTMLElement>(role: import("@testing-library/react/pure").ByRoleMatcher, options?: queries.ByRoleOptions | undefined): ReturnType<queries.QueryByRole<T>>;
142
+ queryAllByRole<T extends HTMLElement = HTMLElement>(role: import("@testing-library/react/pure").ByRoleMatcher, options?: queries.ByRoleOptions | undefined): ReturnType<queries.AllByRole<T>>;
143
+ findByRole<T extends HTMLElement = HTMLElement>(role: import("@testing-library/react/pure").ByRoleMatcher, options?: queries.ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindByRole<T>>;
144
+ findAllByRole<T extends HTMLElement = HTMLElement>(role: import("@testing-library/react/pure").ByRoleMatcher, options?: queries.ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindAllByRole<T>>;
145
+ getByTestId<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.GetByBoundAttribute<T>>;
146
+ getAllByTestId<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.AllByBoundAttribute<T>>;
147
+ queryByTestId<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.QueryByBoundAttribute<T>>;
148
+ queryAllByTestId<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined): ReturnType<queries.AllByBoundAttribute<T>>;
149
+ findByTestId<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindByBoundAttribute<T>>;
150
+ findAllByTestId<T extends HTMLElement = HTMLElement>(id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined): ReturnType<queries.FindAllByBoundAttribute<T>>;
151
+ } & {
152
+ queryDescriptionOf: (args_0: Element) => HTMLElement | null;
153
+ queryAllDescriptionsOf: (element: Element) => HTMLElement[];
154
+ getDescriptionOf: (args_0: Element) => HTMLElement;
155
+ getAllDescriptionsOf: (args_0: Element) => HTMLElement[];
156
+ findDescriptionOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement>;
157
+ findAllDescriptionsOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement[]>;
158
+ getByLabelText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined) => HTMLElement;
159
+ getAllByLabelText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined) => HTMLElement[];
160
+ queryByLabelText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined) => HTMLElement | null;
161
+ queryAllByLabelText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined) => HTMLElement[];
162
+ findByLabelText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement>;
163
+ findAllByLabelText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement[]>;
164
+ getByPlaceholderText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement;
165
+ getAllByPlaceholderText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement[];
166
+ queryByPlaceholderText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement | null;
167
+ queryAllByPlaceholderText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement[];
168
+ findByPlaceholderText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement>;
169
+ findAllByPlaceholderText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement[]>;
170
+ getByText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined) => HTMLElement;
171
+ getAllByText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined) => HTMLElement[];
172
+ queryByText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined) => HTMLElement | null;
173
+ queryAllByText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined) => HTMLElement[];
174
+ findByText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement>;
175
+ findAllByText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement[]>;
176
+ getByAltText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement;
177
+ getAllByAltText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement[];
178
+ queryByAltText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement | null;
179
+ queryAllByAltText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement[];
180
+ findByAltText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement>;
181
+ findAllByAltText: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement[]>;
182
+ getByTitle: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement;
183
+ getAllByTitle: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement[];
184
+ queryByTitle: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement | null;
185
+ queryAllByTitle: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement[];
186
+ findByTitle: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement>;
187
+ findAllByTitle: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement[]>;
188
+ getByDisplayValue: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement;
189
+ getAllByDisplayValue: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement[];
190
+ queryByDisplayValue: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement | null;
191
+ queryAllByDisplayValue: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement[];
192
+ findByDisplayValue: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement>;
193
+ findAllByDisplayValue: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement[]>;
194
+ getByRole: (role: import("@testing-library/react/pure").ByRoleMatcher, options?: queries.ByRoleOptions | undefined) => HTMLElement;
195
+ getAllByRole: (role: import("@testing-library/react/pure").ByRoleMatcher, options?: queries.ByRoleOptions | undefined) => HTMLElement[];
196
+ queryByRole: (role: import("@testing-library/react/pure").ByRoleMatcher, options?: queries.ByRoleOptions | undefined) => HTMLElement | null;
197
+ queryAllByRole: (role: import("@testing-library/react/pure").ByRoleMatcher, options?: queries.ByRoleOptions | undefined) => HTMLElement[];
198
+ findByRole: (role: import("@testing-library/react/pure").ByRoleMatcher, options?: queries.ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement>;
199
+ findAllByRole: (role: import("@testing-library/react/pure").ByRoleMatcher, options?: queries.ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement[]>;
200
+ getByTestId: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement;
201
+ getAllByTestId: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement[];
202
+ queryByTestId: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement | null;
203
+ queryAllByTestId: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined) => HTMLElement[];
204
+ findByTestId: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement>;
205
+ findAllByTestId: (id: import("@testing-library/react/pure").Matcher, options?: import("@testing-library/react/pure").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react/pure").waitForOptions | undefined) => Promise<HTMLElement[]>;
206
+ };
207
+ export { renderHook, waitFor, within, createEvent, type RenderHookResult, type EventType } from '@testing-library/react/pure';
208
+ export { act, fireEvent };
209
+ export declare const screen: Screen & typeof bodyBoundQueries;
210
+ export declare function flushEffects(): Promise<void>;
211
+ /**
212
+ * returns true when touch is suported and can be mocked
213
+ */
214
+ export declare function supportsTouch(): boolean;
@@ -0,0 +1,428 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.act = act;
9
+ Object.defineProperty(exports, "createEvent", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _pure.createEvent;
13
+ }
14
+ });
15
+ exports.createRenderer = createRenderer;
16
+ exports.fireEvent = void 0;
17
+ exports.fireTouchChangedEvent = fireTouchChangedEvent;
18
+ exports.flushEffects = flushEffects;
19
+ Object.defineProperty(exports, "renderHook", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _pure.renderHook;
23
+ }
24
+ });
25
+ exports.screen = void 0;
26
+ exports.supportsTouch = supportsTouch;
27
+ Object.defineProperty(exports, "waitFor", {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _pure.waitFor;
31
+ }
32
+ });
33
+ Object.defineProperty(exports, "within", {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _pure.within;
37
+ }
38
+ });
39
+ var _cache = _interopRequireDefault(require("@emotion/cache"));
40
+ var _react = require("@emotion/react");
41
+ var _pure = require("@testing-library/react/pure");
42
+ var _userEvent = require("@testing-library/user-event");
43
+ var React = _interopRequireWildcard(require("react"));
44
+ var ReactDOMServer = _interopRequireWildcard(require("react-dom/server"));
45
+ var _vitest = require("vitest");
46
+ var _reactMajor = _interopRequireDefault(require("./reactMajor"));
47
+ var _jsxRuntime = require("react/jsx-runtime");
48
+ /* eslint-disable compat/compat -- Test environment */
49
+
50
+ function queryAllDescriptionsOf(baseElement, element) {
51
+ const ariaDescribedBy = element.getAttribute('aria-describedby');
52
+ if (ariaDescribedBy === null) {
53
+ return [];
54
+ }
55
+ return ariaDescribedBy.split(' ').map(id => {
56
+ return document.getElementById(id);
57
+ }).filter(maybeElement => {
58
+ return maybeElement !== null && baseElement.contains(maybeElement);
59
+ });
60
+ }
61
+ const [queryDescriptionOf, getAllDescriptionsOf, getDescriptionOf, findAllDescriptionsOf, findDescriptionOf] = (0, _pure.buildQueries)(queryAllDescriptionsOf, function getMultipleError() {
62
+ return `Found multiple descriptions.`;
63
+ }, function getMissingError() {
64
+ return `Found no describing element.`;
65
+ });
66
+ const customQueries = {
67
+ queryDescriptionOf,
68
+ queryAllDescriptionsOf,
69
+ getDescriptionOf,
70
+ getAllDescriptionsOf,
71
+ findDescriptionOf,
72
+ findAllDescriptionsOf
73
+ };
74
+ function render(element, configuration) {
75
+ const {
76
+ container,
77
+ hydrate,
78
+ wrapper,
79
+ reactStrictMode
80
+ } = configuration;
81
+ const testingLibraryRenderResult = (0, _pure.render)(element, {
82
+ container,
83
+ hydrate,
84
+ queries: {
85
+ ..._pure.queries,
86
+ ...customQueries
87
+ },
88
+ wrapper,
89
+ reactStrictMode
90
+ });
91
+ const result = {
92
+ ...testingLibraryRenderResult,
93
+ user: _userEvent.userEvent.setup({
94
+ document
95
+ }),
96
+ forceUpdate() {
97
+ testingLibraryRenderResult.rerender(/*#__PURE__*/React.cloneElement(element, {
98
+ 'data-force-update': String(Math.random())
99
+ }));
100
+ },
101
+ setProps(props) {
102
+ testingLibraryRenderResult.rerender(/*#__PURE__*/React.cloneElement(element, props));
103
+ }
104
+ };
105
+ return result;
106
+ }
107
+ function renderToString(element, configuration) {
108
+ const {
109
+ container,
110
+ wrapper: Wrapper
111
+ } = configuration;
112
+ container.innerHTML = ReactDOMServer.renderToString(/*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapper, {
113
+ children: element
114
+ }));
115
+ return {
116
+ container,
117
+ hydrate() {
118
+ return render(element, {
119
+ ...configuration,
120
+ hydrate: true
121
+ });
122
+ }
123
+ };
124
+ }
125
+ function createClock(defaultMode, config, options) {
126
+ if (defaultMode === 'fake') {
127
+ (0, _vitest.beforeEach)(() => {
128
+ _vitest.vi.useFakeTimers({
129
+ now: config,
130
+ // useIsFocusVisible schedules a global timer that needs to persist regardless of whether components are mounted or not.
131
+ // Technically we'd want to reset all modules between tests but we don't have that technology.
132
+ // In the meantime just continue to clear native timers like we did for the past years when using `sinon` < 8.
133
+ shouldClearNativeTimers: true,
134
+ toFake: ['setTimeout', 'setInterval', 'clearTimeout', 'clearInterval', 'requestAnimationFrame', 'cancelAnimationFrame', 'performance', 'Date'],
135
+ ...options
136
+ });
137
+ if (config) {
138
+ _vitest.vi.setSystemTime(config);
139
+ }
140
+ });
141
+ } else {
142
+ (0, _vitest.beforeEach)(() => {
143
+ if (config) {
144
+ _vitest.vi.setSystemTime(config);
145
+ }
146
+ });
147
+ }
148
+ (0, _vitest.afterEach)(async () => {
149
+ if (_vitest.vi.isFakeTimers()) {
150
+ await (0, _pure.act)(async () => {
151
+ _vitest.vi.runOnlyPendingTimers();
152
+ });
153
+ _vitest.vi.useRealTimers();
154
+ }
155
+ });
156
+ return {
157
+ withFakeTimers: () => {
158
+ if (_vitest.vi.isFakeTimers()) {
159
+ return;
160
+ }
161
+ (0, _vitest.beforeEach)(() => {
162
+ _vitest.vi.useFakeTimers({
163
+ now: config,
164
+ // useIsFocusVisible schedules a global timer that needs to persist regardless of whether components are mounted or not.
165
+ // Technically we'd want to reset all modules between tests but we don't have that technology.
166
+ // In the meantime just continue to clear native timers like we did for the past years when using `sinon` < 8.
167
+ shouldClearNativeTimers: true,
168
+ toFake: ['setTimeout', 'setInterval', 'clearTimeout', 'clearInterval', 'requestAnimationFrame', 'cancelAnimationFrame', 'performance', 'Date'],
169
+ ...options
170
+ });
171
+ if (config) {
172
+ _vitest.vi.setSystemTime(config);
173
+ }
174
+ });
175
+ },
176
+ runToLast: () => {
177
+ (0, _pure.act)(() => {
178
+ _vitest.vi.runOnlyPendingTimers();
179
+ });
180
+ },
181
+ isReal() {
182
+ return !_vitest.vi.isFakeTimers();
183
+ },
184
+ restore() {
185
+ _vitest.vi.useRealTimers();
186
+ },
187
+ tick(timeoutMS) {
188
+ (0, _pure.act)(() => {
189
+ _vitest.vi.advanceTimersByTime(timeoutMS);
190
+ });
191
+ },
192
+ runAll() {
193
+ (0, _pure.act)(() => {
194
+ _vitest.vi.runAllTimers();
195
+ });
196
+ }
197
+ };
198
+ }
199
+ function createRenderer(globalOptions = {}) {
200
+ const {
201
+ clock: clockMode = 'real',
202
+ clockConfig,
203
+ strict: globalStrict = true,
204
+ strictEffects: globalStrictEffects = globalStrict,
205
+ clockOptions
206
+ } = globalOptions;
207
+ // save stack to re-use in test-hooks
208
+ const {
209
+ stack: createClientRenderStack
210
+ } = new Error();
211
+ const clock = createClock(clockMode, clockConfig, clockOptions);
212
+
213
+ /**
214
+ * Flag whether `createRenderer` was called in a suite i.e. describe() block.
215
+ * For legacy reasons `createRenderer` might accidentally be called in a beforeAll(Each) hook.
216
+ */
217
+ let wasCalledInSuite = false;
218
+ (0, _vitest.beforeAll)(function beforeHook() {
219
+ wasCalledInSuite = true;
220
+ });
221
+ let emotionCache = null;
222
+ /**
223
+ * target container for SSR
224
+ */
225
+ let serverContainer;
226
+ /**
227
+ * Flag whether all setup for `configuredClientRender` was completed.
228
+ * For legacy reasons `configuredClientRender` might accidentally be called in a beforeAll(Each) hook.
229
+ */
230
+ let prepared = false;
231
+ (0, _vitest.beforeEach)(function beforeEachHook() {
232
+ if (!wasCalledInSuite) {
233
+ const error = new Error('Unable to run `before` hook for `createRenderer`. This usually indicates that `createRenderer` was called in a `before` hook instead of in a `describe()` block.');
234
+ error.stack = createClientRenderStack;
235
+ throw error;
236
+ }
237
+ const id = _vitest.expect.getState().currentTestName;
238
+ if (!id) {
239
+ throw new Error('Unable to find the currently running test. This is a bug with the client-renderer. Please report this issue to a maintainer.');
240
+ }
241
+ emotionCache = (0, _cache.default)({
242
+ key: 'emotion-client-render'
243
+ });
244
+ serverContainer = document.createElement('div');
245
+ document.body.appendChild(serverContainer);
246
+ prepared = true;
247
+ });
248
+ (0, _vitest.afterEach)(() => {
249
+ if (!clock.isReal()) {
250
+ const error = new Error("Can't cleanup before fake timers are restored.\n" + 'Be sure to:\n' + ' 1. Only use `clock` from `createRenderer`.\n' + ' 2. Call `createRenderer` in a suite and not any test hook (for example `beforeEach`) or test itself (for example `it`).');
251
+ // Use saved stack otherwise the stack trace will not include the test location.
252
+ error.stack = createClientRenderStack;
253
+ throw error;
254
+ }
255
+ (0, _pure.cleanup)();
256
+ emotionCache.sheet.tags.forEach(styleTag => {
257
+ styleTag.remove();
258
+ });
259
+ emotionCache = null;
260
+ serverContainer.remove();
261
+ serverContainer = null;
262
+ });
263
+ function createWrapper(options) {
264
+ const {
265
+ wrapper: InnerWrapper = React.Fragment
266
+ } = options;
267
+ return function Wrapper({
268
+ children
269
+ }) {
270
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.CacheProvider, {
271
+ value: emotionCache,
272
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(InnerWrapper, {
273
+ children: children
274
+ })
275
+ });
276
+ };
277
+ }
278
+ return {
279
+ clock,
280
+ render(element, options = {}) {
281
+ if (!prepared) {
282
+ throw new Error('Unable to finish setup before `render()` was called. ' + 'This usually indicates that `render()` was called in a `beforeAll()` or `beforeEach` hook. ' + 'Move the call into each `it()`. Otherwise you cannot run a specific test and we cannot isolate each test.');
283
+ }
284
+ const usesLegacyRoot = _reactMajor.default < 18;
285
+ const reactStrictMode = (options.strict ?? globalStrict) && ((options.strictEffects ?? globalStrictEffects) || usesLegacyRoot);
286
+ return render(element, {
287
+ ...options,
288
+ reactStrictMode,
289
+ hydrate: false,
290
+ wrapper: createWrapper(options)
291
+ });
292
+ },
293
+ renderToString(element, options = {}) {
294
+ if (!prepared) {
295
+ throw new Error('Unable to finish setup before `render()` was called. ' + 'This usually indicates that `render()` was called in a `beforeAll()` or `beforeEach` hook. ' + 'Move the call into each `it()`. Otherwise you cannot run a specific test and we cannot isolate each test.');
296
+ }
297
+ const {
298
+ container = serverContainer,
299
+ ...localOptions
300
+ } = options;
301
+ return renderToString(element, {
302
+ ...localOptions,
303
+ container,
304
+ wrapper: createWrapper(options)
305
+ });
306
+ }
307
+ };
308
+ }
309
+ const fireEvent = (target, event, ...args) => {
310
+ return (0, _pure.fireEvent)(target, event, ...args);
311
+ };
312
+ exports.fireEvent = fireEvent;
313
+ Object.keys(_pure.fireEvent).forEach(
314
+ // @ts-expect-error
315
+ eventType => {
316
+ fireEvent[eventType] = (...args) => _pure.fireEvent[eventType](...args);
317
+ });
318
+ const originalFireEventKeyDown = _pure.fireEvent.keyDown;
319
+ fireEvent.keyDown = (desiredTarget, options = {}) => {
320
+ const element = desiredTarget;
321
+ // `element` shouldn't be `document` but we catch this later anyway
322
+ const document = element.ownerDocument || element;
323
+ const target = document.activeElement || document.body || document.documentElement;
324
+ if (target !== element) {
325
+ // see https://www.w3.org/TR/uievents/#keydown
326
+ const error = new Error(`\`keydown\` events can only be targeted at the active element which is ${(0, _pure.prettyDOM)(target, undefined, {
327
+ maxDepth: 1
328
+ })}`);
329
+ // We're only interested in the callsite of fireEvent.keyDown
330
+ error.stack = error.stack.split('\n').filter(line => !/at Function.key/.test(line)).join('\n');
331
+ throw error;
332
+ }
333
+ return originalFireEventKeyDown(element, options);
334
+ };
335
+ const originalFireEventKeyUp = _pure.fireEvent.keyUp;
336
+ fireEvent.keyUp = (desiredTarget, options = {}) => {
337
+ const element = desiredTarget;
338
+ // `element` shouldn't be `document` but we catch this later anyway
339
+ const document = element.ownerDocument || element;
340
+ const target = document.activeElement || document.body || document.documentElement;
341
+ if (target !== element) {
342
+ // see https://www.w3.org/TR/uievents/#keyup
343
+ const error = new Error(`\`keyup\` events can only be targeted at the active element which is ${(0, _pure.prettyDOM)(target, undefined, {
344
+ maxDepth: 1
345
+ })}`);
346
+ // We're only interested in the callsite of fireEvent.keyUp
347
+ error.stack = error.stack.split('\n').filter(line => !/at Function.key/.test(line)).join('\n');
348
+ throw error;
349
+ }
350
+ return originalFireEventKeyUp(element, options);
351
+ };
352
+ function fireTouchChangedEvent(target, type, options) {
353
+ const {
354
+ changedTouches
355
+ } = options;
356
+ const originalGetBoundingClientRect = target.getBoundingClientRect;
357
+ target.getBoundingClientRect = () => ({
358
+ x: 0,
359
+ y: 0,
360
+ bottom: 0,
361
+ height: 0,
362
+ left: 0,
363
+ right: 0,
364
+ top: 0,
365
+ width: 0,
366
+ toJSON() {
367
+ return {
368
+ x: 0,
369
+ y: 0,
370
+ bottom: 0,
371
+ height: 0,
372
+ left: 0,
373
+ right: 0,
374
+ top: 0,
375
+ width: 0
376
+ };
377
+ }
378
+ });
379
+ const event = new window.TouchEvent(type, {
380
+ bubbles: true,
381
+ cancelable: true,
382
+ composed: true,
383
+ changedTouches: changedTouches.map(opts => new window.Touch({
384
+ target,
385
+ identifier: 0,
386
+ ...opts
387
+ }))
388
+ });
389
+ fireEvent(target, event);
390
+ target.getBoundingClientRect = originalGetBoundingClientRect;
391
+ }
392
+ function act(callback) {
393
+ return (0, _pure.act)(callback);
394
+ }
395
+ const bodyBoundQueries = (0, _pure.within)(document.body, {
396
+ ..._pure.queries,
397
+ ...customQueries
398
+ });
399
+ const screen = exports.screen = {
400
+ ..._pure.screen,
401
+ ...bodyBoundQueries
402
+ };
403
+ async function flushEffects() {
404
+ await act(async () => {});
405
+ }
406
+
407
+ /**
408
+ * returns true when touch is suported and can be mocked
409
+ */
410
+ function supportsTouch() {
411
+ // only run in supported browsers
412
+ if (typeof Touch === 'undefined') {
413
+ return false;
414
+ }
415
+ try {
416
+ // eslint-disable-next-line no-new
417
+ new Touch({
418
+ identifier: 0,
419
+ target: window,
420
+ pageX: 0,
421
+ pageY: 0
422
+ });
423
+ } catch {
424
+ // Touch constructor not supported
425
+ return false;
426
+ }
427
+ return true;
428
+ }
@@ -0,0 +1 @@
1
+ export {};