@trackunit/react-core-contexts-test 0.1.228 → 0.1.229
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.
- package/HookRenderer.cjs.js +2 -2
- package/HookRenderer.esm.js +2 -2
- package/index.cjs2.js +27 -24
- package/index.esm2.js +28 -25
- package/package.json +1 -1
- package/src/ApolloMockedProviderWithError.d.ts +6 -1
- package/src/HookRenderer.d.ts +1 -1
- package/src/TrackunitProvidersMockBuilder.d.ts +6 -14
- package/src/debugger.d.ts +1 -1
- package/src/mocks/mockAnalyticsContext.d.ts +1 -1
- package/src/utils/routingUtils.d.ts +11 -3
package/HookRenderer.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index.cjs2.js');
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
4
|
var react = require('@testing-library/react');
|
|
6
5
|
var pure = require('@testing-library/react/pure');
|
|
6
|
+
require('react/jsx-runtime');
|
|
7
7
|
require('@trackunit/react-core-hooks');
|
|
8
8
|
require('lodash/omit');
|
|
9
9
|
require('@apollo/client');
|
|
@@ -28,7 +28,7 @@ const reactHooksRenderHook = (callback, getMockedCompositionRoot) => index.__awa
|
|
|
28
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
29
|
const wrapper = ({ children }) => {
|
|
30
30
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
31
|
-
return getMockedCompositionRoot(
|
|
31
|
+
return getMockedCompositionRoot(children);
|
|
32
32
|
};
|
|
33
33
|
let renderedHook;
|
|
34
34
|
// This is added here to make storybook work and to ensure the right act is loaded for hooks.
|
package/HookRenderer.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as __awaiter, f as flushPromises } from './index.esm2.js';
|
|
2
|
-
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
2
|
import { act } from '@testing-library/react';
|
|
4
3
|
import { renderHook } from '@testing-library/react/pure';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
5
5
|
import '@trackunit/react-core-hooks';
|
|
6
6
|
import 'lodash/omit';
|
|
7
7
|
import '@apollo/client';
|
|
@@ -26,7 +26,7 @@ const reactHooksRenderHook = (callback, getMockedCompositionRoot) => __awaiter(v
|
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
27
|
const wrapper = ({ children }) => {
|
|
28
28
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
29
|
-
return getMockedCompositionRoot(
|
|
29
|
+
return getMockedCompositionRoot(children);
|
|
30
30
|
};
|
|
31
31
|
let renderedHook;
|
|
32
32
|
// This is added here to make storybook work and to ensure the right act is loaded for hooks.
|
package/index.cjs2.js
CHANGED
|
@@ -72,9 +72,8 @@ const defaultOptions = {
|
|
|
72
72
|
/**
|
|
73
73
|
* This is a wrapper around the MockedProvider that logs errors to the console.
|
|
74
74
|
*/
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
75
|
function ApolloMockedProviderWithError(props) {
|
|
77
|
-
const isDebugging =
|
|
76
|
+
const isDebugging = !!process.env.VSCODE_INSPECTOR_OPTIONS || !!process.env.DEBUG;
|
|
78
77
|
const { mocks } = props, otherProps = __rest(props, ["mocks"]);
|
|
79
78
|
const mockLink = new testing.MockLink(mocks, false, { showWarnings: props.forceDebugging || isDebugging });
|
|
80
79
|
const errorLoggingLink = error.onError(({ graphQLErrors, networkError }) => {
|
|
@@ -87,11 +86,9 @@ function ApolloMockedProviderWithError(props) {
|
|
|
87
86
|
}
|
|
88
87
|
});
|
|
89
88
|
}
|
|
90
|
-
if (networkError) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
console.log(`[Network error]: ${networkError}`);
|
|
94
|
-
}
|
|
89
|
+
if (networkError && (props.forceDebugging || isDebugging)) {
|
|
90
|
+
// eslint-disable-next-line no-console
|
|
91
|
+
console.log(`[Network error]: ${networkError}`);
|
|
95
92
|
}
|
|
96
93
|
});
|
|
97
94
|
const link = client.ApolloLink.from([errorLoggingLink, mockLink]);
|
|
@@ -302,32 +299,34 @@ const TestRenderChildren = ({ addTestRootContainer, children }) => {
|
|
|
302
299
|
* @param selectedRouterProps selected router props
|
|
303
300
|
* @param rootRoute root route
|
|
304
301
|
* @param children children to be wrapped
|
|
305
|
-
* @returns React.ReactElement
|
|
302
|
+
* @returns {React.ReactElement} children component wrapped in a test root container
|
|
306
303
|
*/
|
|
307
304
|
const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute, children, }) => {
|
|
308
305
|
var _a, _b;
|
|
309
306
|
const client = react.useApolloClient();
|
|
310
307
|
// The current version of createMemoryHistory seem to have issues when NOT ending on / so adding a # will not effect what url is rendered but it seems to work
|
|
311
|
-
const memoryHistory = reactRouter.createMemoryHistory({
|
|
308
|
+
const memoryHistory = React.useRef(reactRouter.createMemoryHistory({
|
|
312
309
|
initialEntries: (_b = (_a = selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.initialEntries) === null || _a === void 0 ? void 0 : _a.map(entry => entry.path + "#")) !== null && _b !== void 0 ? _b : ["/#"],
|
|
313
310
|
initialIndex: 0,
|
|
314
|
-
});
|
|
311
|
+
}));
|
|
315
312
|
const getChildren = React.useCallback(() => children, [children]);
|
|
316
313
|
const router = React.useMemo(() => {
|
|
317
314
|
var _a, _b;
|
|
318
|
-
|
|
319
|
-
|
|
315
|
+
let localRootRoute = rootRoute;
|
|
316
|
+
if (!localRootRoute) {
|
|
317
|
+
const route = reactRouter.createRootRoute({ component: RootRouteDebugger });
|
|
320
318
|
const childRoute = reactRouter.createRoute({
|
|
321
319
|
path: "/",
|
|
322
|
-
getParentRoute: () =>
|
|
320
|
+
getParentRoute: () => route,
|
|
323
321
|
component: () => {
|
|
324
322
|
return jsxRuntime.jsx(TestRenderChildren, { addTestRootContainer: addTestRootContainer, children: getChildren() });
|
|
325
323
|
},
|
|
326
324
|
});
|
|
327
|
-
|
|
325
|
+
route.addChildren([childRoute]);
|
|
326
|
+
localRootRoute = route;
|
|
328
327
|
}
|
|
329
328
|
else {
|
|
330
|
-
const pathsToRoute = buildFlatRouteMap([
|
|
329
|
+
const pathsToRoute = buildFlatRouteMap([localRootRoute]);
|
|
331
330
|
sharedUtils.objectValues(pathsToRoute).forEach(route => {
|
|
332
331
|
route.options.component = RootRouteDebugger;
|
|
333
332
|
route.lazyFn = undefined;
|
|
@@ -362,16 +361,16 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
|
|
|
362
361
|
else {
|
|
363
362
|
const childRoute = reactRouter.createRoute({
|
|
364
363
|
path: "/",
|
|
365
|
-
getParentRoute: () =>
|
|
364
|
+
getParentRoute: () => localRootRoute,
|
|
366
365
|
component: () => (jsxRuntime.jsx(TestRenderChildren, { addTestRootContainer: addTestRootContainer, children: getChildren() })),
|
|
367
366
|
});
|
|
368
|
-
|
|
367
|
+
localRootRoute.addChildren([childRoute]);
|
|
369
368
|
}
|
|
370
369
|
}
|
|
371
370
|
}
|
|
372
371
|
return reactRouter.createRouter({
|
|
373
|
-
routeTree:
|
|
374
|
-
history: memoryHistory,
|
|
372
|
+
routeTree: localRootRoute,
|
|
373
|
+
history: memoryHistory.current,
|
|
375
374
|
context: {
|
|
376
375
|
hasAccessTo: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
377
376
|
return true;
|
|
@@ -384,10 +383,14 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
|
|
|
384
383
|
isAuthenticated: true,
|
|
385
384
|
},
|
|
386
385
|
});
|
|
386
|
+
// Skipping this rule for now.
|
|
387
|
+
// Explicit calls to rerender() will create a new router as `children` is changed.
|
|
388
|
+
// This causes unexpected state updates in Tanstack router which make the test fail
|
|
389
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
387
390
|
}, [rootRoute]);
|
|
388
391
|
const context = React.useMemo(() => (Object.assign({ hasAccessTo: () => __awaiter(void 0, void 0, void 0, function* () { return true; }), isAuthenticated: true, client, defaultUserRoute: "/" }, ((selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.context) || {}))), [client, selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.context]);
|
|
389
|
-
const ErrorComponent = ({ error
|
|
390
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: ["UNCAUGHT ERROR IN TEST: ", error
|
|
392
|
+
const ErrorComponent = ({ error }) => {
|
|
393
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: ["UNCAUGHT ERROR IN TEST: ", error && error instanceof Error ? error.message : error] });
|
|
391
394
|
};
|
|
392
395
|
return jsxRuntime.jsx(reactRouter.RouterProvider, { context: context, defaultErrorComponent: ErrorComponent, router: router });
|
|
393
396
|
};
|
|
@@ -638,7 +641,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
638
641
|
userSubscription(userSubscription) {
|
|
639
642
|
var _a;
|
|
640
643
|
//TODO DONT SUPPORT THE WIERD WAY OF PASSING FEATURES
|
|
641
|
-
const featuresConverted = ((_a = userSubscription
|
|
644
|
+
const featuresConverted = ((_a = userSubscription.features) === null || _a === void 0 ? void 0 : _a.map(f => {
|
|
642
645
|
if (typeof f === "string") {
|
|
643
646
|
return { id: f, name: f };
|
|
644
647
|
}
|
|
@@ -823,9 +826,9 @@ class TrackunitProvidersMockBuilder {
|
|
|
823
826
|
}
|
|
824
827
|
/**
|
|
825
828
|
* Validate the mocks that has been supplied to make sure they make sense.
|
|
826
|
-
* Note: This function is
|
|
829
|
+
* Note: This function is overridden in builders extending this one.
|
|
827
830
|
*
|
|
828
|
-
* @returns {boolean}
|
|
831
|
+
* @returns {boolean} true or throws error if any invalid mocks
|
|
829
832
|
*/
|
|
830
833
|
validateSuppliedMocks() {
|
|
831
834
|
return true;
|
package/index.esm2.js
CHANGED
|
@@ -9,7 +9,7 @@ import { AssetSortByProperty, SortOrder } from '@trackunit/react-core-contexts-a
|
|
|
9
9
|
import { useApolloClient } from '@apollo/client/react';
|
|
10
10
|
import { createMemoryHistory, createRootRoute, createRoute, createRouter, RouterProvider, Outlet } from '@tanstack/react-router';
|
|
11
11
|
import { objectValues, objectKeys } from '@trackunit/shared-utils';
|
|
12
|
-
import React, { useCallback, useMemo,
|
|
12
|
+
import React, { useRef, useCallback, useMemo, useEffect } from 'react';
|
|
13
13
|
import { GraphQLError } from 'graphql';
|
|
14
14
|
|
|
15
15
|
/******************************************************************************
|
|
@@ -65,9 +65,8 @@ const defaultOptions = {
|
|
|
65
65
|
/**
|
|
66
66
|
* This is a wrapper around the MockedProvider that logs errors to the console.
|
|
67
67
|
*/
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
68
|
function ApolloMockedProviderWithError(props) {
|
|
70
|
-
const isDebugging =
|
|
69
|
+
const isDebugging = !!process.env.VSCODE_INSPECTOR_OPTIONS || !!process.env.DEBUG;
|
|
71
70
|
const { mocks } = props, otherProps = __rest(props, ["mocks"]);
|
|
72
71
|
const mockLink = new MockLink(mocks, false, { showWarnings: props.forceDebugging || isDebugging });
|
|
73
72
|
const errorLoggingLink = onError(({ graphQLErrors, networkError }) => {
|
|
@@ -80,11 +79,9 @@ function ApolloMockedProviderWithError(props) {
|
|
|
80
79
|
}
|
|
81
80
|
});
|
|
82
81
|
}
|
|
83
|
-
if (networkError) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
console.log(`[Network error]: ${networkError}`);
|
|
87
|
-
}
|
|
82
|
+
if (networkError && (props.forceDebugging || isDebugging)) {
|
|
83
|
+
// eslint-disable-next-line no-console
|
|
84
|
+
console.log(`[Network error]: ${networkError}`);
|
|
88
85
|
}
|
|
89
86
|
});
|
|
90
87
|
const link = ApolloLink.from([errorLoggingLink, mockLink]);
|
|
@@ -295,32 +292,34 @@ const TestRenderChildren = ({ addTestRootContainer, children }) => {
|
|
|
295
292
|
* @param selectedRouterProps selected router props
|
|
296
293
|
* @param rootRoute root route
|
|
297
294
|
* @param children children to be wrapped
|
|
298
|
-
* @returns React.ReactElement
|
|
295
|
+
* @returns {React.ReactElement} children component wrapped in a test root container
|
|
299
296
|
*/
|
|
300
297
|
const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute, children, }) => {
|
|
301
298
|
var _a, _b;
|
|
302
299
|
const client = useApolloClient();
|
|
303
300
|
// The current version of createMemoryHistory seem to have issues when NOT ending on / so adding a # will not effect what url is rendered but it seems to work
|
|
304
|
-
const memoryHistory = createMemoryHistory({
|
|
301
|
+
const memoryHistory = useRef(createMemoryHistory({
|
|
305
302
|
initialEntries: (_b = (_a = selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.initialEntries) === null || _a === void 0 ? void 0 : _a.map(entry => entry.path + "#")) !== null && _b !== void 0 ? _b : ["/#"],
|
|
306
303
|
initialIndex: 0,
|
|
307
|
-
});
|
|
304
|
+
}));
|
|
308
305
|
const getChildren = useCallback(() => children, [children]);
|
|
309
306
|
const router = useMemo(() => {
|
|
310
307
|
var _a, _b;
|
|
311
|
-
|
|
312
|
-
|
|
308
|
+
let localRootRoute = rootRoute;
|
|
309
|
+
if (!localRootRoute) {
|
|
310
|
+
const route = createRootRoute({ component: RootRouteDebugger });
|
|
313
311
|
const childRoute = createRoute({
|
|
314
312
|
path: "/",
|
|
315
|
-
getParentRoute: () =>
|
|
313
|
+
getParentRoute: () => route,
|
|
316
314
|
component: () => {
|
|
317
315
|
return jsx(TestRenderChildren, { addTestRootContainer: addTestRootContainer, children: getChildren() });
|
|
318
316
|
},
|
|
319
317
|
});
|
|
320
|
-
|
|
318
|
+
route.addChildren([childRoute]);
|
|
319
|
+
localRootRoute = route;
|
|
321
320
|
}
|
|
322
321
|
else {
|
|
323
|
-
const pathsToRoute = buildFlatRouteMap([
|
|
322
|
+
const pathsToRoute = buildFlatRouteMap([localRootRoute]);
|
|
324
323
|
objectValues(pathsToRoute).forEach(route => {
|
|
325
324
|
route.options.component = RootRouteDebugger;
|
|
326
325
|
route.lazyFn = undefined;
|
|
@@ -355,16 +354,16 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
|
|
|
355
354
|
else {
|
|
356
355
|
const childRoute = createRoute({
|
|
357
356
|
path: "/",
|
|
358
|
-
getParentRoute: () =>
|
|
357
|
+
getParentRoute: () => localRootRoute,
|
|
359
358
|
component: () => (jsx(TestRenderChildren, { addTestRootContainer: addTestRootContainer, children: getChildren() })),
|
|
360
359
|
});
|
|
361
|
-
|
|
360
|
+
localRootRoute.addChildren([childRoute]);
|
|
362
361
|
}
|
|
363
362
|
}
|
|
364
363
|
}
|
|
365
364
|
return createRouter({
|
|
366
|
-
routeTree:
|
|
367
|
-
history: memoryHistory,
|
|
365
|
+
routeTree: localRootRoute,
|
|
366
|
+
history: memoryHistory.current,
|
|
368
367
|
context: {
|
|
369
368
|
hasAccessTo: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
370
369
|
return true;
|
|
@@ -377,10 +376,14 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
|
|
|
377
376
|
isAuthenticated: true,
|
|
378
377
|
},
|
|
379
378
|
});
|
|
379
|
+
// Skipping this rule for now.
|
|
380
|
+
// Explicit calls to rerender() will create a new router as `children` is changed.
|
|
381
|
+
// This causes unexpected state updates in Tanstack router which make the test fail
|
|
382
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
380
383
|
}, [rootRoute]);
|
|
381
384
|
const context = useMemo(() => (Object.assign({ hasAccessTo: () => __awaiter(void 0, void 0, void 0, function* () { return true; }), isAuthenticated: true, client, defaultUserRoute: "/" }, ((selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.context) || {}))), [client, selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.context]);
|
|
382
|
-
const ErrorComponent = ({ error
|
|
383
|
-
return jsxs(Fragment, { children: ["UNCAUGHT ERROR IN TEST: ", error
|
|
385
|
+
const ErrorComponent = ({ error }) => {
|
|
386
|
+
return jsxs(Fragment, { children: ["UNCAUGHT ERROR IN TEST: ", error && error instanceof Error ? error.message : error] });
|
|
384
387
|
};
|
|
385
388
|
return jsx(RouterProvider, { context: context, defaultErrorComponent: ErrorComponent, router: router });
|
|
386
389
|
};
|
|
@@ -631,7 +634,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
631
634
|
userSubscription(userSubscription) {
|
|
632
635
|
var _a;
|
|
633
636
|
//TODO DONT SUPPORT THE WIERD WAY OF PASSING FEATURES
|
|
634
|
-
const featuresConverted = ((_a = userSubscription
|
|
637
|
+
const featuresConverted = ((_a = userSubscription.features) === null || _a === void 0 ? void 0 : _a.map(f => {
|
|
635
638
|
if (typeof f === "string") {
|
|
636
639
|
return { id: f, name: f };
|
|
637
640
|
}
|
|
@@ -816,9 +819,9 @@ class TrackunitProvidersMockBuilder {
|
|
|
816
819
|
}
|
|
817
820
|
/**
|
|
818
821
|
* Validate the mocks that has been supplied to make sure they make sense.
|
|
819
|
-
* Note: This function is
|
|
822
|
+
* Note: This function is overridden in builders extending this one.
|
|
820
823
|
*
|
|
821
|
-
* @returns {boolean}
|
|
824
|
+
* @returns {boolean} true or throws error if any invalid mocks
|
|
822
825
|
*/
|
|
823
826
|
validateSuppliedMocks() {
|
|
824
827
|
return true;
|
package/package.json
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { MockLink } from "@apollo/client/testing";
|
|
2
3
|
/**
|
|
3
4
|
* This is a wrapper around the MockedProvider that logs errors to the console.
|
|
4
5
|
*/
|
|
5
|
-
export declare function ApolloMockedProviderWithError(props:
|
|
6
|
+
export declare function ApolloMockedProviderWithError(props: {
|
|
7
|
+
mocks: ConstructorParameters<typeof MockLink>[0];
|
|
8
|
+
forceDebugging?: boolean;
|
|
9
|
+
[k: string]: unknown;
|
|
10
|
+
}): JSX.Element;
|
package/src/HookRenderer.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ import * as React from "react";
|
|
|
8
8
|
* @param getMockedCompositionRoot A function that will return the mocked composition root.
|
|
9
9
|
* @returns { Promise<RenderHookResult> } The rendered hook.
|
|
10
10
|
*/
|
|
11
|
-
export declare const reactHooksRenderHook: <TProps, TResult>(callback: (props: TProps) => TResult, getMockedCompositionRoot: (children: React.
|
|
11
|
+
export declare const reactHooksRenderHook: <TProps, TResult>(callback: (props: TProps) => TResult, getMockedCompositionRoot: (children: React.ReactNode) => React.ReactElement) => Promise<RenderHookResult<TResult, TProps>>;
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { MockedResponse } from "@apollo/client/testing";
|
|
2
|
-
import { AnyRoute
|
|
2
|
+
import { AnyRoute } from "@tanstack/react-router";
|
|
3
3
|
import { RenderResult } from "@testing-library/react";
|
|
4
4
|
import { AssetSortingContextValue, ConfirmationDialogContextValue, FilterBarValues, IAnalyticsContext, ICurrentUserContext, IEnvironmentContext, INavigationContext, IOemBrandingContext, IToastContext, ITokenContext, IUserPreferencesContext, IUserSubscriptionContext, ModalDialogContextValue } from "@trackunit/react-core-contexts-api";
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
|
|
7
|
-
routeTree?: T;
|
|
8
|
-
initialEntries?: {
|
|
9
|
-
route: RouteIds<RegisteredRouter["routeTree"]>;
|
|
10
|
-
path: string;
|
|
11
|
-
component?: () => JSX.Element | null;
|
|
12
|
-
}[];
|
|
13
|
-
context?: Record<string, unknown>;
|
|
14
|
-
};
|
|
6
|
+
import { MemoryRouterProps } from "./utils/routingUtils";
|
|
15
7
|
/**
|
|
16
8
|
* This builder allows you to enable trackunit providers using the builder pattern, and then call 1 of either:
|
|
17
9
|
* For React Components:
|
|
@@ -34,7 +26,7 @@ export declare class TrackunitProvidersMockBuilder<T extends AnyRoute> {
|
|
|
34
26
|
protected selectedAssetSortingContext: AssetSortingContextValue;
|
|
35
27
|
protected selectedCurrentUserContext: ICurrentUserContext;
|
|
36
28
|
protected selectedCurrentUserPreferenceContext: IUserPreferencesContext;
|
|
37
|
-
protected selectedAnalyticsContext: IAnalyticsContext<
|
|
29
|
+
protected selectedAnalyticsContext: IAnalyticsContext<Record<string, never>>;
|
|
38
30
|
protected selectedOemBrandingContext: IOemBrandingContext;
|
|
39
31
|
protected selectedUserSubscriptionContext: IUserSubscriptionContext;
|
|
40
32
|
protected selectedFilterBarValues: FilterBarValues;
|
|
@@ -349,9 +341,9 @@ export declare class TrackunitProvidersMockBuilder<T extends AnyRoute> {
|
|
|
349
341
|
apollo(apolloMocks?: MockedResponse[]): this;
|
|
350
342
|
/**
|
|
351
343
|
* Validate the mocks that has been supplied to make sure they make sense.
|
|
352
|
-
* Note: This function is
|
|
344
|
+
* Note: This function is overridden in builders extending this one.
|
|
353
345
|
*
|
|
354
|
-
* @returns {boolean}
|
|
346
|
+
* @returns {boolean} true or throws error if any invalid mocks
|
|
355
347
|
*/
|
|
356
348
|
protected validateSuppliedMocks(): true | never;
|
|
357
349
|
protected rootRoute(rootRoute: AnyRoute | null): this;
|
|
@@ -365,7 +357,7 @@ export declare class TrackunitProvidersMockBuilder<T extends AnyRoute> {
|
|
|
365
357
|
/**
|
|
366
358
|
* This will return the mocked composition root.
|
|
367
359
|
*/
|
|
368
|
-
renderHook<TProps, TResult>(callback: (props: TProps) => TResult, parentElement?: (children: React.
|
|
360
|
+
renderHook<TProps, TResult>(callback: (props: TProps) => TResult, parentElement?: (children: React.ReactNode) => React.ReactElement): Promise<import("@testing-library/react").RenderHookResult<TResult, TProps>>;
|
|
369
361
|
/**
|
|
370
362
|
* This will use react-testing-library.render the child in the correct mocked hierarchy of context providers.
|
|
371
363
|
*
|
package/src/debugger.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IAnalyticsContext } from "@trackunit/react-core-contexts-api";
|
|
2
|
-
export declare const mockAnalyticsContext: IAnalyticsContext<
|
|
2
|
+
export declare const mockAnalyticsContext: IAnalyticsContext<Record<string, never>>;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { AnyRoute } from "@tanstack/react-router";
|
|
1
|
+
import { AnyRoute, RegisteredRouter, RouteIds } from "@tanstack/react-router";
|
|
2
2
|
import React from "react";
|
|
3
|
-
|
|
3
|
+
export type MemoryRouterProps<T extends AnyRoute> = {
|
|
4
|
+
routeTree?: T;
|
|
5
|
+
initialEntries?: {
|
|
6
|
+
route: RouteIds<RegisteredRouter["routeTree"]>;
|
|
7
|
+
path: string;
|
|
8
|
+
component?: () => JSX.Element | null;
|
|
9
|
+
}[];
|
|
10
|
+
context?: Record<string, unknown>;
|
|
11
|
+
};
|
|
4
12
|
/**
|
|
5
13
|
* This component is used to wrap the children of the RouterContainer to add a test root container
|
|
6
14
|
*/
|
|
@@ -33,6 +41,6 @@ export interface RouterContainerProps<T extends AnyRoute = AnyRoute> {
|
|
|
33
41
|
* @param selectedRouterProps selected router props
|
|
34
42
|
* @param rootRoute root route
|
|
35
43
|
* @param children children to be wrapped
|
|
36
|
-
* @returns React.ReactElement
|
|
44
|
+
* @returns {React.ReactElement} children component wrapped in a test root container
|
|
37
45
|
*/
|
|
38
46
|
export declare const RouterContainer: ({ addTestRootContainer, selectedRouterProps, rootRoute, children, }: RouterContainerProps) => React.ReactElement;
|