@trackunit/react-core-contexts-test 0.1.75 → 0.1.77

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.
@@ -1,304 +1,326 @@
1
- import { MockedResponse } from "@apollo/client/testing";
2
- import { RenderResult } from "@testing-library/react";
3
- import { IAnalyticsContext, IAssetSortingContext, ICurrentUserContext, IEnvironmentContext, IGlobalSelectionContext, IOemBrandingContext, IToastContext, ITokenContext, IUserSubscriptionContext } from "@trackunit/react-core-contexts-api";
4
- import * as React from "react";
5
- import { MemoryRouterProps } from "react-router-dom";
6
- /**
7
- * This builder allows you to enable trackunit providers using the builder pattern, and then call 1 of either:
8
- * For React Components:
9
- * - render
10
- * For React Hooks:
11
- * - renderHook
12
- * For Storybook:
13
- * - storybook
14
- */
15
- export declare class TrackunitProvidersMockBuilder {
16
- protected selectedEnvironmentContext: IEnvironmentContext;
17
- protected selectedTokenContext: ITokenContext;
18
- protected selectedApolloMocks: MockedResponse[];
19
- protected selectedRouterProps: MemoryRouterProps;
20
- protected selectedToastContext: IToastContext;
21
- protected selectedGlobalSelection: IGlobalSelectionContext;
22
- protected selectedAssetSortingContext: IAssetSortingContext;
23
- protected selectedCurrentUserContext: ICurrentUserContext;
24
- protected selectedAnalyticsContext: IAnalyticsContext<{}>;
25
- protected selectedOemBrandingContext: IOemBrandingContext;
26
- protected selectedUserSubscriptionContext: IUserSubscriptionContext;
27
- /**
28
- * Use this Analytics Context.
29
- * Defaults to mockAnalyticsContext.
30
- *
31
- * @see mockAnalyticsContext
32
- * @example
33
- * ...
34
- * it("should allow render", async () => {
35
- * await trackunitProviders().analytics(yourPartialAnalyticsMock).render(<YourTestComponent data-testid="yourTestId" />);
36
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
37
- * });
38
- * ...
39
- * @example
40
- * ...
41
- * it("should allow renderHook", async () => {
42
- * const { result } = await trackunitProviders().analytics(yourPartialAnalyticsMock).renderHook(() => useYourTestHook());
43
- * expect(result.current).toEqual(anything());
44
- * });
45
- * ...
46
- * @param analyticsContext - The analytics context to use.
47
- * @returns { TrackunitProvidersMockBuilder } - The builder.
48
- */
49
- analytics(analyticsContext: Partial<IAnalyticsContext<any>>): this;
50
- /**
51
- * Use this Environment Context.
52
- * Defaults to mockEnvironmentContext.
53
- *
54
- * @see mockEnvironmentContext
55
- * @example
56
- * ...
57
- * it("should allow render", async () => {
58
- * await trackunitProviders().environment(yourPartialEnvironmentsMock).render(<YourTestComponent data-testid="yourTestId" />);
59
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
60
- * });
61
- * ...
62
- * @example
63
- * ...
64
- * it("should allow renderHook", async () => {
65
- * const { result } = await trackunitProviders().environment(yourPartialEnvironmentMock).renderHook(() => useYourTestHook());
66
- * expect(result.current).toEqual(anything());
67
- * });
68
- * ...
69
- * @param environmentContext - The environment context to use.
70
- * @returns { TrackunitProvidersMockBuilder } - The builder.
71
- */
72
- environment(environmentContext: Partial<IEnvironmentContext>): this;
73
- /**
74
- * Use this to pass in a differerent current user.
75
- * Defaults to mockCurrentUserContext.
76
- *
77
- * @see mockCurrentUserContext
78
- * @example
79
- * ...
80
- * it("should allow render", async () => {
81
- * await trackunitProviders().currentUser(yourPartialCurrentUserMock).render(<YourTestComponent data-testid="yourTestId" />);
82
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
83
- * });
84
- * ...
85
- * @example
86
- * ...
87
- * it("should allow renderHook", async () => {
88
- * const { result } = await trackunitProviders().currentUser(yourPartialCurrentUserMock).renderHook(() => useYourTestHook());
89
- * expect(result.current).toEqual(anything());
90
- * });
91
- * ...
92
- * @returns { TrackunitProvidersMockBuilder } - The builder.
93
- */
94
- currentUser(currentUserContext: Partial<ICurrentUserContext>): this;
95
- /**
96
- * Use this to pass in a differerent current user subscription.
97
- * Defaults to mockUserSubscriptionContext.
98
- *
99
- * @see mockUserSubscriptionContext
100
- * @example
101
- * ...
102
- * it("should allow render", async () => {
103
- * await trackunitProviders().userSubscription(yourPartialUserSubscriptionMock).render(<YourTestComponent data-testid="yourTestId" />);
104
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
105
- * });
106
- * ...
107
- * @example
108
- * ...
109
- * it("should allow renderHook", async () => {
110
- * const { result } = await trackunitProviders().userSubscription(yourPartialUserSubscriptionMock).renderHook(() => useYourTestHook());
111
- * expect(result.current).toEqual(anything());
112
- * });
113
- * ...
114
- * @returns { TrackunitProvidersMockBuilder } - The builder.
115
- */
116
- userSubscription(userSubscription: Partial<IUserSubscriptionContext> | {
117
- features: string[];
118
- }): this;
119
- /**
120
- * Set global asset sorting context.
121
- * Defaults to mockAssetSortingContext.
122
- *
123
- * @see mockAssetSortingContext
124
- * @example
125
- * ...
126
- * it("should allow render", async () => {
127
- * await trackunitProviders().assetSorting(yourPartialAssetSortingMock).render(<YourTestComponent data-testid="yourTestId" />);
128
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
129
- * });
130
- * ...
131
- * @example
132
- * ...
133
- * it("should allow renderHook", async () => {
134
- * const { result } = await trackunitProviders().assetSorting(yourPartialAssetSortingMock).renderHook(() => useYourTestHook());
135
- * expect(result.current).toEqual(anything());
136
- * });
137
- * ...
138
- * @param assetSortingContext - Override the default context.
139
- * @returns { TrackunitProvidersMockBuilder } - The builder.
140
- */
141
- assetSorting(assetSortingContext: Partial<IAssetSortingContext>): this;
142
- /**
143
- * Set OEM Branding context.
144
- * Defaults to mockOemBrandingContext.
145
- *
146
- * @see mockOemBrandingContext
147
- * @example
148
- * ...
149
- * it("should allow render", async () => {
150
- * await trackunitProviders().oemBrandingContext(yourPartialOemBrandingMock).render(<YourTestComponent data-testid="yourTestId" />);
151
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
152
- * });
153
- * ...
154
- * @example
155
- * ...
156
- * it("should allow renderHook", async () => {
157
- * const { result } = await trackunitProviders().oemBrandingContext(yourPartialOemBrandingMock).renderHook(() => useYourTestHook());
158
- * expect(result.current).toEqual(anything());
159
- * });
160
- * ...
161
- * @param oemBrandingContext - Override the default context.
162
- */
163
- oemBrandingContext(oemBrandingContext: Partial<IOemBrandingContext>): this;
164
- /**
165
- * Use this ToastContext with the given mocks.
166
- * Defaults to mockToastContext.
167
- *
168
- * @see mockToastContext
169
- * @example
170
- * ...
171
- * it("should allow render", async () => {
172
- * await trackunitProviders().toast(yourPartialToastMock).render(<YourTestComponent data-testid="yourTestId" />);
173
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
174
- * });
175
- * ...
176
- * @example
177
- * ...
178
- * it("should allow renderHook", async () => {
179
- * const { result } = await trackunitProviders().toast(yourPartialToastMock).renderHook(() => useYourTestHook());
180
- * expect(result.current).toEqual(anything());
181
- * });
182
- * ...
183
- * @param toastContext - Override the default toast context.
184
- */
185
- toast(toastContext: Partial<IToastContext>): this;
186
- /**
187
- * Use this global selection.
188
- * Defaults to null.
189
- *
190
- * @example
191
- * ...
192
- * it("should allow render", async () => {
193
- * await trackunitProviders().globalSelection(yourGlobalSelectionMock).render(<YourTestComponent data-testid="yourTestId" />);
194
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
195
- * });
196
- * ...
197
- * @example
198
- * ...
199
- * it("should allow renderHook", async () => {
200
- * const { result } = await trackunitProviders().globalSelection(yourGlobalSelectionMock).renderHook(() => useYourTestHook());
201
- * expect(result.current).toEqual(anything());
202
- * });
203
- * ...
204
- * @param globalSelection - The global selection to use.
205
- * @returns { TrackunitProvidersMockBuilder } - The builder.
206
- */
207
- globalSelection(globalSelection: IGlobalSelectionContext["selection"]): this;
208
- /**
209
- * Use this token.
210
- *
211
- * @example
212
- * ...
213
- * it("should allow render", async () => {
214
- * await trackunitProviders().token(yourMockedToken).render(<YourTestComponent data-testid="yourTestId" />);
215
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
216
- * });
217
- * ...
218
- * @example
219
- * ...
220
- * it("should allow renderHook", async () => {
221
- * const { result } = await trackunitProviders().token(yourMockedToken).renderHook(() => useYourTestHook());
222
- * expect(result.current).toEqual(anything());
223
- * });
224
- * ...
225
- * @param token - The token to use.
226
- * @returns { TrackunitProvidersMockBuilder } - The builder.
227
- */
228
- token(token: string): this;
229
- /**
230
- * Use this Router Props with the given mocks.
231
- *
232
- * @example
233
- * ...
234
- * it("should allow render", async () => {
235
- * await trackunitProviders().routerProps(yourRouterPropsMock).render(<YourTestComponent data-testid="yourTestId" />);
236
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
237
- * });
238
- * ...
239
- * @example
240
- * ...
241
- * it("should allow renderHook", async () => {
242
- * const { result } = await trackunitProviders().routerProps(yourRouterPropsMock).renderHook(() => useYourTestHook());
243
- * expect(result.current).toEqual(anything());
244
- * });
245
- * ...
246
- * @param routerProps - The router props to use.
247
- * @returns { TrackunitProvidersMockBuilder } - The builder.
248
- */
249
- routerProps(routerProps: MemoryRouterProps): this;
250
- /**
251
- * Use this Manager Apollo Context Provider with the given mocks.
252
- *
253
- * @see https://www.apollographql.com/docs/react/development-testing/testing
254
- * @example
255
- * ...
256
- * it("should allow render", async () => {
257
- * await trackunitProviders().apollo([yourApolloMocks]).render(<YourTestComponent data-testid="yourTestId" />);
258
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
259
- * });
260
- * ...
261
- * @example
262
- * ...
263
- * it("should allow renderHook", async () => {
264
- * const { result } = await trackunitProviders().apollo([yourApolloMocks]).renderHook(() => useYourTestHook());
265
- * expect(result.current).toEqual(anything());
266
- * });
267
- * ...
268
- * @param apolloMocks - The mocks to use for the ApolloProvider.
269
- */
270
- apollo(apolloMocks?: MockedResponse[]): this;
271
- /**
272
- * Validate the mocks that has been supplied to make sure they make sense.
273
- * Note: This function is overriden in builders extending this one.
274
- *
275
- * @returns {boolean} true or throws error if any invalid mocks
276
- */
277
- protected validateSuppliedMocks(): true | never;
278
- /**
279
- * Make sure this represent the same structure as the main index.tsx does.
280
- *
281
- * @param testChildren - the child element being tested.
282
- * @param addTestRootContainer - if you want to add a root container to the test.
283
- */
284
- protected getMockedCompositionRoot(testChildren: React.ReactNode, addTestRootContainer?: boolean): JSX.Element;
285
- /**
286
- * This will return the mocked composition root.
287
- */
288
- renderHook<TProps, TResult>(callback: (props: TProps) => TResult, parentElement?: (children: React.ReactElement) => React.ReactElement): Promise<import("@testing-library/react").RenderHookResult<TResult, TProps>>;
289
- /**
290
- * This will use react-testing-library.render the child in the correct mocked hierarchy of context providers.
291
- *
292
- * @see https://testing-library.com/docs/react-testing-library/api#render
293
- * @param child - the child element being tested.
294
- */
295
- render(child: React.ReactElement): Promise<RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>>;
296
- /**
297
- * This will return the children in the correct mocked hierarchy of context providers.
298
- */
299
- storybook(child: React.ReactNode): JSX.Element;
300
- }
301
- /**
302
- * This is the default mock builder for the TrackunitProviders.
303
- */
304
- export declare const trackunitProviders: () => TrackunitProvidersMockBuilder;
1
+ import { MockedResponse } from "@apollo/client/testing";
2
+ import { RenderResult } from "@testing-library/react";
3
+ import { IAnalyticsContext, IAssetSortingContext, ICurrentUserContext, IEnvironmentContext, IGlobalSelectionContext, IOemBrandingContext, IToastContext, ITokenContext, IUserSubscriptionContext } from "@trackunit/react-core-contexts-api";
4
+ import * as React from "react";
5
+ import { MemoryRouterProps } from "react-router-dom";
6
+ /**
7
+ * This builder allows you to enable trackunit providers using the builder pattern, and then call 1 of either:
8
+ * For React Components:
9
+ * - render
10
+ * For React Hooks:
11
+ * - renderHook
12
+ * For Storybook:
13
+ * - storybook
14
+ */
15
+ export declare class TrackunitProvidersMockBuilder {
16
+ protected selectedEnvironmentContext: IEnvironmentContext;
17
+ protected selectedTokenContext: ITokenContext;
18
+ protected selectedApolloMocks: MockedResponse[];
19
+ protected selectedRouterProps: MemoryRouterProps;
20
+ protected selectedToastContext: IToastContext;
21
+ protected selectedGlobalSelection: IGlobalSelectionContext;
22
+ protected selectedAssetSortingContext: IAssetSortingContext;
23
+ protected selectedCurrentUserContext: ICurrentUserContext;
24
+ protected selectedAnalyticsContext: IAnalyticsContext<{}>;
25
+ protected selectedOemBrandingContext: IOemBrandingContext;
26
+ protected selectedUserSubscriptionContext: IUserSubscriptionContext;
27
+ /**
28
+ * Use this Analytics Context.
29
+ * Defaults to mockAnalyticsContext.
30
+ *
31
+ * This context is used by the useAnalytics hook from lib "@trackunit/react-core-hooks"
32
+ *
33
+ * @see mockAnalyticsContext
34
+ * @example
35
+ * ...
36
+ * it("should allow render", async () => {
37
+ * await trackunitProviders().analytics(yourPartialAnalyticsMock).render(<YourTestComponent data-testid="yourTestId" />);
38
+ * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
39
+ * });
40
+ * ...
41
+ * @example
42
+ * ...
43
+ * it("should allow renderHook", async () => {
44
+ * const { result } = await trackunitProviders().analytics(yourPartialAnalyticsMock).renderHook(() => useYourTestHook());
45
+ * expect(result.current).toEqual(anything());
46
+ * });
47
+ * ...
48
+ * @param analyticsContext - The analytics context to use.
49
+ * @returns { TrackunitProvidersMockBuilder } - The builder.
50
+ */
51
+ analytics(analyticsContext: Partial<IAnalyticsContext<any>>): this;
52
+ /**
53
+ * Use this Environment Context.
54
+ * Defaults to mockEnvironmentContext.
55
+ *
56
+ * This context is used by the useEnvironment hook from lib "@trackunit/react-core-hooks"
57
+ *
58
+ * @see mockEnvironmentContext
59
+ * @example
60
+ * ...
61
+ * it("should allow render", async () => {
62
+ * await trackunitProviders().environment(yourPartialEnvironmentsMock).render(<YourTestComponent data-testid="yourTestId" />);
63
+ * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
64
+ * });
65
+ * ...
66
+ * @example
67
+ * ...
68
+ * it("should allow renderHook", async () => {
69
+ * const { result } = await trackunitProviders().environment(yourPartialEnvironmentMock).renderHook(() => useYourTestHook());
70
+ * expect(result.current).toEqual(anything());
71
+ * });
72
+ * ...
73
+ * @param environmentContext - The environment context to use.
74
+ * @returns { TrackunitProvidersMockBuilder } - The builder.
75
+ */
76
+ environment(environmentContext: Partial<IEnvironmentContext>): this;
77
+ /**
78
+ * Use this to pass in a differerent current user.
79
+ * Defaults to mockCurrentUserContext.
80
+ *
81
+ * This context is used by the useCurrentUser hook from lib "@trackunit/react-core-hooks"
82
+ *
83
+ * @see mockCurrentUserContext
84
+ * @example
85
+ * ...
86
+ * it("should allow render", async () => {
87
+ * await trackunitProviders().currentUser(yourPartialCurrentUserMock).render(<YourTestComponent data-testid="yourTestId" />);
88
+ * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
89
+ * });
90
+ * ...
91
+ * @example
92
+ * ...
93
+ * it("should allow renderHook", async () => {
94
+ * const { result } = await trackunitProviders().currentUser(yourPartialCurrentUserMock).renderHook(() => useYourTestHook());
95
+ * expect(result.current).toEqual(anything());
96
+ * });
97
+ * ...
98
+ * @returns { TrackunitProvidersMockBuilder } - The builder.
99
+ */
100
+ currentUser(currentUserContext: Partial<ICurrentUserContext>): this;
101
+ /**
102
+ * Use this to pass in a differerent current user subscription.
103
+ * Defaults to mockUserSubscriptionContext.
104
+ *
105
+ * This context is used by the useUserSubscription hook from lib "@trackunit/react-core-hooks"
106
+ *
107
+ * @see mockUserSubscriptionContext
108
+ * @example
109
+ * ...
110
+ * it("should allow render", async () => {
111
+ * await trackunitProviders().userSubscription(yourPartialUserSubscriptionMock).render(<YourTestComponent data-testid="yourTestId" />);
112
+ * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
113
+ * });
114
+ * ...
115
+ * @example
116
+ * ...
117
+ * it("should allow renderHook", async () => {
118
+ * const { result } = await trackunitProviders().userSubscription(yourPartialUserSubscriptionMock).renderHook(() => useYourTestHook());
119
+ * expect(result.current).toEqual(anything());
120
+ * });
121
+ * ...
122
+ * @returns { TrackunitProvidersMockBuilder } - The builder.
123
+ */
124
+ userSubscription(userSubscription: Partial<IUserSubscriptionContext> | {
125
+ features: string[];
126
+ }): this;
127
+ /**
128
+ * Set global asset sorting context.
129
+ * Defaults to mockAssetSortingContext.
130
+ *
131
+ * This context is used by the useAssetSorting hook from lib "@trackunit/react-core-hooks"
132
+ *
133
+ * @see mockAssetSortingContext
134
+ * @example
135
+ * ...
136
+ * it("should allow render", async () => {
137
+ * await trackunitProviders().assetSorting(yourPartialAssetSortingMock).render(<YourTestComponent data-testid="yourTestId" />);
138
+ * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
139
+ * });
140
+ * ...
141
+ * @example
142
+ * ...
143
+ * it("should allow renderHook", async () => {
144
+ * const { result } = await trackunitProviders().assetSorting(yourPartialAssetSortingMock).renderHook(() => useYourTestHook());
145
+ * expect(result.current).toEqual(anything());
146
+ * });
147
+ * ...
148
+ * @param assetSortingContext - Override the default context.
149
+ * @returns { TrackunitProvidersMockBuilder } - The builder.
150
+ */
151
+ assetSorting(assetSortingContext: Partial<IAssetSortingContext>): this;
152
+ /**
153
+ * Set OEM Branding context.
154
+ * Defaults to mockOemBrandingContext.
155
+ *
156
+ * This context is used by the useAssetSorting hook from lib "@trackunit/react-core-hooks"
157
+ *
158
+ * @see mockOemBrandingContext
159
+ * @example
160
+ * ...
161
+ * it("should allow render", async () => {
162
+ * await trackunitProviders().oemBrandingContext(yourPartialOemBrandingMock).render(<YourTestComponent data-testid="yourTestId" />);
163
+ * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
164
+ * });
165
+ * ...
166
+ * @example
167
+ * ...
168
+ * it("should allow renderHook", async () => {
169
+ * const { result } = await trackunitProviders().oemBrandingContext(yourPartialOemBrandingMock).renderHook(() => useYourTestHook());
170
+ * expect(result.current).toEqual(anything());
171
+ * });
172
+ * ...
173
+ * @param oemBrandingContext - Override the default context.
174
+ */
175
+ oemBrandingContext(oemBrandingContext: Partial<IOemBrandingContext>): this;
176
+ /**
177
+ * Use this ToastContext with the given mocks.
178
+ * Defaults to mockToastContext.
179
+ *
180
+ * This context is used by the useToast hook from lib "@trackunit/react-core-hooks"
181
+ *
182
+ * @see mockToastContext
183
+ * @example
184
+ * ...
185
+ * it("should allow render", async () => {
186
+ * await trackunitProviders().toast(yourPartialToastMock).render(<YourTestComponent data-testid="yourTestId" />);
187
+ * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
188
+ * });
189
+ * ...
190
+ * @example
191
+ * ...
192
+ * it("should allow renderHook", async () => {
193
+ * const { result } = await trackunitProviders().toast(yourPartialToastMock).renderHook(() => useYourTestHook());
194
+ * expect(result.current).toEqual(anything());
195
+ * });
196
+ * ...
197
+ * @param toastContext - Override the default toast context.
198
+ */
199
+ toast(toastContext: Partial<IToastContext>): this;
200
+ /**
201
+ * Use this global selection.
202
+ * Defaults to null.
203
+ *
204
+ * This context is used by the useGlobalSelection hook from lib "@trackunit/react-core-hooks"
205
+ *
206
+ * @example
207
+ * ...
208
+ * it("should allow render", async () => {
209
+ * await trackunitProviders().globalSelection(yourGlobalSelectionMock).render(<YourTestComponent data-testid="yourTestId" />);
210
+ * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
211
+ * });
212
+ * ...
213
+ * @example
214
+ * ...
215
+ * it("should allow renderHook", async () => {
216
+ * const { result } = await trackunitProviders().globalSelection(yourGlobalSelectionMock).renderHook(() => useYourTestHook());
217
+ * expect(result.current).toEqual(anything());
218
+ * });
219
+ * ...
220
+ * @param globalSelection - The global selection to use.
221
+ * @returns { TrackunitProvidersMockBuilder } - The builder.
222
+ */
223
+ globalSelection(globalSelection: IGlobalSelectionContext["selection"]): this;
224
+ /**
225
+ * Use this token.
226
+ *
227
+ * This context is used by the useToken hook from lib "@trackunit/react-core-hooks"
228
+ *
229
+ * @example
230
+ * ...
231
+ * it("should allow render", async () => {
232
+ * await trackunitProviders().token(yourMockedToken).render(<YourTestComponent data-testid="yourTestId" />);
233
+ * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
234
+ * });
235
+ * ...
236
+ * @example
237
+ * ...
238
+ * it("should allow renderHook", async () => {
239
+ * const { result } = await trackunitProviders().token(yourMockedToken).renderHook(() => useYourTestHook());
240
+ * expect(result.current).toEqual(anything());
241
+ * });
242
+ * ...
243
+ * @param token - The token to use.
244
+ * @returns { TrackunitProvidersMockBuilder } - The builder.
245
+ */
246
+ token(token: string): this;
247
+ /**
248
+ * Use this Router Props with the given mocks.
249
+ *
250
+ * This is used to provide a MemoryRouter from lib "react-router-dom"
251
+ *
252
+ * @example
253
+ * ...
254
+ * it("should allow render", async () => {
255
+ * await trackunitProviders().routerProps(yourRouterPropsMock).render(<YourTestComponent data-testid="yourTestId" />);
256
+ * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
257
+ * });
258
+ * ...
259
+ * @example
260
+ * ...
261
+ * it("should allow renderHook", async () => {
262
+ * const { result } = await trackunitProviders().routerProps(yourRouterPropsMock).renderHook(() => useYourTestHook());
263
+ * expect(result.current).toEqual(anything());
264
+ * });
265
+ * ...
266
+ * @param routerProps - The router props to use.
267
+ * @returns { TrackunitProvidersMockBuilder } - The builder.
268
+ */
269
+ routerProps(routerProps: MemoryRouterProps): this;
270
+ /**
271
+ * Use this Manager Apollo Context Provider with the given mocks.
272
+ *
273
+ * This context is used by the useQuery and useLazyQuery hook from lib "@apollo/client"
274
+ *
275
+ * @see https://www.apollographql.com/docs/react/development-testing/testing
276
+ * @example
277
+ * ...
278
+ * it("should allow render", async () => {
279
+ * await trackunitProviders().apollo([yourApolloMocks]).render(<YourTestComponent data-testid="yourTestId" />);
280
+ * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
281
+ * });
282
+ * ...
283
+ * @example
284
+ * ...
285
+ * it("should allow renderHook", async () => {
286
+ * const { result } = await trackunitProviders().apollo([yourApolloMocks]).renderHook(() => useYourTestHook());
287
+ * expect(result.current).toEqual(anything());
288
+ * });
289
+ * ...
290
+ * @param apolloMocks - The mocks to use for the ApolloProvider.
291
+ */
292
+ apollo(apolloMocks?: MockedResponse[]): this;
293
+ /**
294
+ * Validate the mocks that has been supplied to make sure they make sense.
295
+ * Note: This function is overriden in builders extending this one.
296
+ *
297
+ * @returns {boolean} true or throws error if any invalid mocks
298
+ */
299
+ protected validateSuppliedMocks(): true | never;
300
+ /**
301
+ * Make sure this represent the same structure as the main index.tsx does.
302
+ *
303
+ * @param testChildren - the child element being tested.
304
+ * @param addTestRootContainer - if you want to add a root container to the test.
305
+ */
306
+ protected getMockedCompositionRoot(testChildren: React.ReactNode, addTestRootContainer?: boolean): JSX.Element;
307
+ /**
308
+ * This will return the mocked composition root.
309
+ */
310
+ renderHook<TProps, TResult>(callback: (props: TProps) => TResult, parentElement?: (children: React.ReactElement) => React.ReactElement): Promise<import("@testing-library/react").RenderHookResult<TResult, TProps>>;
311
+ /**
312
+ * This will use react-testing-library.render the child in the correct mocked hierarchy of context providers.
313
+ *
314
+ * @see https://testing-library.com/docs/react-testing-library/api#render
315
+ * @param child - the child element being tested.
316
+ */
317
+ render(child: React.ReactElement): Promise<RenderResult>;
318
+ /**
319
+ * This will return the children in the correct mocked hierarchy of context providers.
320
+ */
321
+ storybook(child: React.ReactNode): JSX.Element;
322
+ }
323
+ /**
324
+ * This is the default mock builder for the TrackunitProviders.
325
+ */
326
+ export declare const trackunitProviders: () => TrackunitProvidersMockBuilder;