@trackunit/react-core-contexts-test 0.1.238 → 0.1.240
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 +1 -1
- package/HookRenderer.esm.js +1 -1
- package/index.cjs.js +1 -1
- package/index.cjs2.js +30 -7
- package/index.esm.js +1 -1
- package/index.esm2.js +31 -8
- package/package.json +1 -1
- package/src/TrackunitProvidersMockBuilder.d.ts +8 -2
- package/src/mocks/mockErrorHandlerContext.d.ts +7 -0
package/HookRenderer.cjs.js
CHANGED
|
@@ -10,9 +10,9 @@ require('@apollo/client');
|
|
|
10
10
|
require('@apollo/client/link/error');
|
|
11
11
|
require('@apollo/client/testing');
|
|
12
12
|
require('@trackunit/react-core-contexts-api');
|
|
13
|
+
require('@trackunit/shared-utils');
|
|
13
14
|
require('@apollo/client/react');
|
|
14
15
|
require('@tanstack/react-router');
|
|
15
|
-
require('@trackunit/shared-utils');
|
|
16
16
|
require('react');
|
|
17
17
|
require('graphql');
|
|
18
18
|
|
package/HookRenderer.esm.js
CHANGED
|
@@ -8,9 +8,9 @@ import '@apollo/client';
|
|
|
8
8
|
import '@apollo/client/link/error';
|
|
9
9
|
import '@apollo/client/testing';
|
|
10
10
|
import '@trackunit/react-core-contexts-api';
|
|
11
|
+
import '@trackunit/shared-utils';
|
|
11
12
|
import '@apollo/client/react';
|
|
12
13
|
import '@tanstack/react-router';
|
|
13
|
-
import '@trackunit/shared-utils';
|
|
14
14
|
import 'react';
|
|
15
15
|
import 'graphql';
|
|
16
16
|
|
package/index.cjs.js
CHANGED
|
@@ -11,9 +11,9 @@ require('@apollo/client');
|
|
|
11
11
|
require('@apollo/client/link/error');
|
|
12
12
|
require('@apollo/client/testing');
|
|
13
13
|
require('@trackunit/react-core-contexts-api');
|
|
14
|
+
require('@trackunit/shared-utils');
|
|
14
15
|
require('@apollo/client/react');
|
|
15
16
|
require('@tanstack/react-router');
|
|
16
|
-
require('@trackunit/shared-utils');
|
|
17
17
|
require('react');
|
|
18
18
|
require('graphql');
|
|
19
19
|
|
package/index.cjs2.js
CHANGED
|
@@ -8,9 +8,9 @@ var client = require('@apollo/client');
|
|
|
8
8
|
var error = require('@apollo/client/link/error');
|
|
9
9
|
var testing = require('@apollo/client/testing');
|
|
10
10
|
var reactCoreContextsApi = require('@trackunit/react-core-contexts-api');
|
|
11
|
+
var sharedUtils = require('@trackunit/shared-utils');
|
|
11
12
|
var react = require('@apollo/client/react');
|
|
12
13
|
var reactRouter = require('@tanstack/react-router');
|
|
13
|
-
var sharedUtils = require('@trackunit/shared-utils');
|
|
14
14
|
var React = require('react');
|
|
15
15
|
var graphql = require('graphql');
|
|
16
16
|
|
|
@@ -196,6 +196,17 @@ const mockEnvironmentContext = {
|
|
|
196
196
|
reportAccessClientId: "",
|
|
197
197
|
};
|
|
198
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Mocks the ErrorHandlingContextValue
|
|
201
|
+
*
|
|
202
|
+
* @returns {ErrorHandlingContextValue} - Returns the mocked current user context
|
|
203
|
+
*/
|
|
204
|
+
const mockErrorHandlerContext = {
|
|
205
|
+
captureException: sharedUtils.doNothing,
|
|
206
|
+
addBreadcrumb: sharedUtils.doNothing,
|
|
207
|
+
setTag: sharedUtils.doNothing,
|
|
208
|
+
};
|
|
209
|
+
|
|
199
210
|
const mockModalDialogContext = {
|
|
200
211
|
openModal: doNothing,
|
|
201
212
|
closeModal: doNothing,
|
|
@@ -284,7 +295,7 @@ const RootRouteDebugger = () => {
|
|
|
284
295
|
* @returns React.ReactElement
|
|
285
296
|
*/
|
|
286
297
|
const TestRenderChildren = ({ addTestRootContainer, children }) => {
|
|
287
|
-
return addTestRootContainer ? (jsxRuntime.jsx("div", { className: "inline-block h-[1000px] w-[1024px]", "data-testid": "testRoot", style: {
|
|
298
|
+
return addTestRootContainer ? (jsxRuntime.jsx("div", { className: "inline-block h-[1000px] w-[1024px] scale-[.99]", "data-testid": "testRoot", style: {
|
|
288
299
|
"--tw-scale-x": "0.99",
|
|
289
300
|
"--tw-scale-y": "0.99",
|
|
290
301
|
}, children: children })) : (jsxRuntime.jsx("div", { children: children }));
|
|
@@ -469,6 +480,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
469
480
|
this.selectedApolloMocks = [];
|
|
470
481
|
this.selectedRouterProps = null;
|
|
471
482
|
this.selectedToastContext = mockToastContext;
|
|
483
|
+
this.selectedErrorHandler = mockErrorHandlerContext;
|
|
472
484
|
this.selectedConfirmationDialogContext = mockConfirmationDialogContext;
|
|
473
485
|
this.selectedAssetSortingContext = mockAssetSortingContext;
|
|
474
486
|
this.selectedCurrentUserContext = mockCurrentUserContext;
|
|
@@ -761,6 +773,13 @@ class TrackunitProvidersMockBuilder {
|
|
|
761
773
|
this.selectedModalDialogContext = Object.assign(Object.assign({}, mockModalDialogContext), modalDialog);
|
|
762
774
|
return this;
|
|
763
775
|
}
|
|
776
|
+
/**
|
|
777
|
+
* errorHandler
|
|
778
|
+
*/
|
|
779
|
+
errorHandler(errorHandler) {
|
|
780
|
+
this.selectedErrorHandler = Object.assign(Object.assign({}, mockErrorHandlerContext), errorHandler);
|
|
781
|
+
return this;
|
|
782
|
+
}
|
|
764
783
|
/**
|
|
765
784
|
* Use this token.
|
|
766
785
|
*
|
|
@@ -858,8 +877,12 @@ class TrackunitProvidersMockBuilder {
|
|
|
858
877
|
* @param testChildren - the child element being tested.
|
|
859
878
|
* @param addTestRootContainer - if you want to add a root container to the test.
|
|
860
879
|
*/
|
|
861
|
-
getMockedCompositionRoot(testChildren,
|
|
862
|
-
return (jsxRuntime.jsx(reactCoreHooks.CurrentUserProvider, { value: this.selectedCurrentUserContext, children: jsxRuntime.jsx(reactCoreHooks.AnalyticsContext.Provider, { value: this.selectedAnalyticsContext, children: jsxRuntime.jsx(reactCoreHooks.UserSubscriptionProvider, { value: this.selectedUserSubscriptionContext, children: jsxRuntime.jsx(reactCoreHooks.OemBrandingContextProvider, { value: this.selectedOemBrandingContext, children: jsxRuntime.jsx(reactCoreHooks.TokenProvider, { value: this.selectedTokenContext, children: jsxRuntime.jsx(reactCoreHooks.ToastProvider, { value: this.selectedToastContext, children: jsxRuntime.jsx(reactCoreHooks.ConfirmationDialogProvider, { value: this.selectedConfirmationDialogContext, children: jsxRuntime.jsx(reactCoreHooks.FilterBarProvider, { value: { filterBarValues: this.selectedFilterBarValues }, children: jsxRuntime.jsx(reactCoreHooks.AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsxRuntime.jsx(ApolloMockedProviderWithError, { addTypename: false, forceDebugging: forceDebugging, mocks: this.selectedApolloMocks, children: jsxRuntime.jsx(reactCoreHooks.NavigationContextProvider, { value: this.selectedNavigationContext, children: jsxRuntime.jsx(reactCoreHooks.CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: jsxRuntime.jsx(reactCoreHooks.EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsxRuntime.jsx(reactCoreHooks.ModalDialogContextProvider, { value: this.selectedModalDialogContext, children:
|
|
880
|
+
getMockedCompositionRoot(testChildren, forceDebugging = false) {
|
|
881
|
+
return (jsxRuntime.jsx(reactCoreHooks.ErrorHandlingContextProvider, { value: this.selectedErrorHandler, children: jsxRuntime.jsx(reactCoreHooks.CurrentUserProvider, { value: this.selectedCurrentUserContext, children: jsxRuntime.jsx(reactCoreHooks.AnalyticsContext.Provider, { value: this.selectedAnalyticsContext, children: jsxRuntime.jsx(reactCoreHooks.UserSubscriptionProvider, { value: this.selectedUserSubscriptionContext, children: jsxRuntime.jsx(reactCoreHooks.OemBrandingContextProvider, { value: this.selectedOemBrandingContext, children: jsxRuntime.jsx(reactCoreHooks.TokenProvider, { value: this.selectedTokenContext, children: jsxRuntime.jsx(reactCoreHooks.ToastProvider, { value: this.selectedToastContext, children: jsxRuntime.jsx(reactCoreHooks.ConfirmationDialogProvider, { value: this.selectedConfirmationDialogContext, children: jsxRuntime.jsx(reactCoreHooks.FilterBarProvider, { value: { filterBarValues: this.selectedFilterBarValues }, children: jsxRuntime.jsx(reactCoreHooks.AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsxRuntime.jsx(ApolloMockedProviderWithError, { addTypename: false, forceDebugging: forceDebugging, mocks: this.selectedApolloMocks, children: jsxRuntime.jsx(reactCoreHooks.NavigationContextProvider, { value: this.selectedNavigationContext, children: jsxRuntime.jsx(reactCoreHooks.CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: jsxRuntime.jsx(reactCoreHooks.EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsxRuntime.jsx(reactCoreHooks.ModalDialogContextProvider, { value: this.selectedModalDialogContext, children: testChildren }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
882
|
+
}
|
|
883
|
+
getMockedCompositionRootWithRouter(testChildren, addTestRootContainer = true, forceDebugging = false) {
|
|
884
|
+
const childrenWithRouter = (jsxRuntime.jsx(RouterContainer, { addTestRootContainer: addTestRootContainer, rootRoute: this.selectedRootRoute, selectedRouterProps: this.selectedRouterProps, children: testChildren }));
|
|
885
|
+
return this.getMockedCompositionRoot(childrenWithRouter, forceDebugging);
|
|
863
886
|
}
|
|
864
887
|
/**
|
|
865
888
|
* This will return the mocked composition root.
|
|
@@ -869,7 +892,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
869
892
|
this.validateSuppliedMocks();
|
|
870
893
|
// This ensures correct act loading when using hooks and not loaded if this build is used for storybook
|
|
871
894
|
const hookRenderer = yield Promise.resolve().then(function () { return require('./HookRenderer.cjs.js'); });
|
|
872
|
-
return hookRenderer.reactHooksRenderHook(callback, children => this.
|
|
895
|
+
return hookRenderer.reactHooksRenderHook(callback, children => this.getMockedCompositionRootWithRouter(parentElement ? parentElement(children) : children));
|
|
873
896
|
});
|
|
874
897
|
}
|
|
875
898
|
/**
|
|
@@ -884,7 +907,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
884
907
|
let mountedcomponent;
|
|
885
908
|
yield react$1.act(() => __awaiter(this, void 0, void 0, function* () {
|
|
886
909
|
mountedcomponent = react$1.render(child, {
|
|
887
|
-
wrapper: ({ children }) => this.
|
|
910
|
+
wrapper: ({ children }) => this.getMockedCompositionRootWithRouter(children),
|
|
888
911
|
});
|
|
889
912
|
yield flushPromises();
|
|
890
913
|
}));
|
|
@@ -901,7 +924,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
901
924
|
* This will return the children in the correct mocked hierarchy of context providers.
|
|
902
925
|
*/
|
|
903
926
|
storybook(child) {
|
|
904
|
-
return this.getMockedCompositionRoot(child,
|
|
927
|
+
return this.getMockedCompositionRoot(child, true);
|
|
905
928
|
}
|
|
906
929
|
}
|
|
907
930
|
/**
|
package/index.esm.js
CHANGED
|
@@ -7,8 +7,8 @@ import '@apollo/client';
|
|
|
7
7
|
import '@apollo/client/link/error';
|
|
8
8
|
import '@apollo/client/testing';
|
|
9
9
|
import '@trackunit/react-core-contexts-api';
|
|
10
|
+
import '@trackunit/shared-utils';
|
|
10
11
|
import '@apollo/client/react';
|
|
11
12
|
import '@tanstack/react-router';
|
|
12
|
-
import '@trackunit/shared-utils';
|
|
13
13
|
import 'react';
|
|
14
14
|
import 'graphql';
|
package/index.esm2.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { act, render } from '@testing-library/react';
|
|
3
|
-
import { CurrentUserProvider, AnalyticsContext, UserSubscriptionProvider, OemBrandingContextProvider, TokenProvider, ToastProvider, ConfirmationDialogProvider, FilterBarProvider, AssetSortingProvider, NavigationContextProvider, CurrentUserPreferenceProvider, EnvironmentContextProvider, ModalDialogContextProvider } from '@trackunit/react-core-hooks';
|
|
3
|
+
import { ErrorHandlingContextProvider, CurrentUserProvider, AnalyticsContext, UserSubscriptionProvider, OemBrandingContextProvider, TokenProvider, ToastProvider, ConfirmationDialogProvider, FilterBarProvider, AssetSortingProvider, NavigationContextProvider, CurrentUserPreferenceProvider, EnvironmentContextProvider, ModalDialogContextProvider } from '@trackunit/react-core-hooks';
|
|
4
4
|
import omit from 'lodash/omit';
|
|
5
5
|
import { ApolloLink } from '@apollo/client';
|
|
6
6
|
import { onError } from '@apollo/client/link/error';
|
|
7
7
|
import { MockLink, MockedProvider } from '@apollo/client/testing';
|
|
8
8
|
import { AssetSortByProperty, SortOrder } from '@trackunit/react-core-contexts-api';
|
|
9
|
+
import { doNothing as doNothing$1, objectValues, objectKeys } from '@trackunit/shared-utils';
|
|
9
10
|
import { useApolloClient } from '@apollo/client/react';
|
|
10
11
|
import { createMemoryHistory, createRootRoute, createRoute, createRouter, RouterProvider, Outlet } from '@tanstack/react-router';
|
|
11
|
-
import { objectValues, objectKeys } from '@trackunit/shared-utils';
|
|
12
12
|
import React, { useRef, useCallback, useMemo, useEffect } from 'react';
|
|
13
13
|
import { GraphQLError } from 'graphql';
|
|
14
14
|
|
|
@@ -189,6 +189,17 @@ const mockEnvironmentContext = {
|
|
|
189
189
|
reportAccessClientId: "",
|
|
190
190
|
};
|
|
191
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Mocks the ErrorHandlingContextValue
|
|
194
|
+
*
|
|
195
|
+
* @returns {ErrorHandlingContextValue} - Returns the mocked current user context
|
|
196
|
+
*/
|
|
197
|
+
const mockErrorHandlerContext = {
|
|
198
|
+
captureException: doNothing$1,
|
|
199
|
+
addBreadcrumb: doNothing$1,
|
|
200
|
+
setTag: doNothing$1,
|
|
201
|
+
};
|
|
202
|
+
|
|
192
203
|
const mockModalDialogContext = {
|
|
193
204
|
openModal: doNothing,
|
|
194
205
|
closeModal: doNothing,
|
|
@@ -277,7 +288,7 @@ const RootRouteDebugger = () => {
|
|
|
277
288
|
* @returns React.ReactElement
|
|
278
289
|
*/
|
|
279
290
|
const TestRenderChildren = ({ addTestRootContainer, children }) => {
|
|
280
|
-
return addTestRootContainer ? (jsx("div", { className: "inline-block h-[1000px] w-[1024px]", "data-testid": "testRoot", style: {
|
|
291
|
+
return addTestRootContainer ? (jsx("div", { className: "inline-block h-[1000px] w-[1024px] scale-[.99]", "data-testid": "testRoot", style: {
|
|
281
292
|
"--tw-scale-x": "0.99",
|
|
282
293
|
"--tw-scale-y": "0.99",
|
|
283
294
|
}, children: children })) : (jsx("div", { children: children }));
|
|
@@ -462,6 +473,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
462
473
|
this.selectedApolloMocks = [];
|
|
463
474
|
this.selectedRouterProps = null;
|
|
464
475
|
this.selectedToastContext = mockToastContext;
|
|
476
|
+
this.selectedErrorHandler = mockErrorHandlerContext;
|
|
465
477
|
this.selectedConfirmationDialogContext = mockConfirmationDialogContext;
|
|
466
478
|
this.selectedAssetSortingContext = mockAssetSortingContext;
|
|
467
479
|
this.selectedCurrentUserContext = mockCurrentUserContext;
|
|
@@ -754,6 +766,13 @@ class TrackunitProvidersMockBuilder {
|
|
|
754
766
|
this.selectedModalDialogContext = Object.assign(Object.assign({}, mockModalDialogContext), modalDialog);
|
|
755
767
|
return this;
|
|
756
768
|
}
|
|
769
|
+
/**
|
|
770
|
+
* errorHandler
|
|
771
|
+
*/
|
|
772
|
+
errorHandler(errorHandler) {
|
|
773
|
+
this.selectedErrorHandler = Object.assign(Object.assign({}, mockErrorHandlerContext), errorHandler);
|
|
774
|
+
return this;
|
|
775
|
+
}
|
|
757
776
|
/**
|
|
758
777
|
* Use this token.
|
|
759
778
|
*
|
|
@@ -851,8 +870,12 @@ class TrackunitProvidersMockBuilder {
|
|
|
851
870
|
* @param testChildren - the child element being tested.
|
|
852
871
|
* @param addTestRootContainer - if you want to add a root container to the test.
|
|
853
872
|
*/
|
|
854
|
-
getMockedCompositionRoot(testChildren,
|
|
855
|
-
return (jsx(CurrentUserProvider, { value: this.selectedCurrentUserContext, children: jsx(AnalyticsContext.Provider, { value: this.selectedAnalyticsContext, children: jsx(UserSubscriptionProvider, { value: this.selectedUserSubscriptionContext, children: jsx(OemBrandingContextProvider, { value: this.selectedOemBrandingContext, children: jsx(TokenProvider, { value: this.selectedTokenContext, children: jsx(ToastProvider, { value: this.selectedToastContext, children: jsx(ConfirmationDialogProvider, { value: this.selectedConfirmationDialogContext, children: jsx(FilterBarProvider, { value: { filterBarValues: this.selectedFilterBarValues }, children: jsx(AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsx(ApolloMockedProviderWithError, { addTypename: false, forceDebugging: forceDebugging, mocks: this.selectedApolloMocks, children: jsx(NavigationContextProvider, { value: this.selectedNavigationContext, children: jsx(CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: jsx(EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsx(ModalDialogContextProvider, { value: this.selectedModalDialogContext, children:
|
|
873
|
+
getMockedCompositionRoot(testChildren, forceDebugging = false) {
|
|
874
|
+
return (jsx(ErrorHandlingContextProvider, { value: this.selectedErrorHandler, children: jsx(CurrentUserProvider, { value: this.selectedCurrentUserContext, children: jsx(AnalyticsContext.Provider, { value: this.selectedAnalyticsContext, children: jsx(UserSubscriptionProvider, { value: this.selectedUserSubscriptionContext, children: jsx(OemBrandingContextProvider, { value: this.selectedOemBrandingContext, children: jsx(TokenProvider, { value: this.selectedTokenContext, children: jsx(ToastProvider, { value: this.selectedToastContext, children: jsx(ConfirmationDialogProvider, { value: this.selectedConfirmationDialogContext, children: jsx(FilterBarProvider, { value: { filterBarValues: this.selectedFilterBarValues }, children: jsx(AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsx(ApolloMockedProviderWithError, { addTypename: false, forceDebugging: forceDebugging, mocks: this.selectedApolloMocks, children: jsx(NavigationContextProvider, { value: this.selectedNavigationContext, children: jsx(CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: jsx(EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsx(ModalDialogContextProvider, { value: this.selectedModalDialogContext, children: testChildren }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
875
|
+
}
|
|
876
|
+
getMockedCompositionRootWithRouter(testChildren, addTestRootContainer = true, forceDebugging = false) {
|
|
877
|
+
const childrenWithRouter = (jsx(RouterContainer, { addTestRootContainer: addTestRootContainer, rootRoute: this.selectedRootRoute, selectedRouterProps: this.selectedRouterProps, children: testChildren }));
|
|
878
|
+
return this.getMockedCompositionRoot(childrenWithRouter, forceDebugging);
|
|
856
879
|
}
|
|
857
880
|
/**
|
|
858
881
|
* This will return the mocked composition root.
|
|
@@ -862,7 +885,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
862
885
|
this.validateSuppliedMocks();
|
|
863
886
|
// This ensures correct act loading when using hooks and not loaded if this build is used for storybook
|
|
864
887
|
const hookRenderer = yield import('./HookRenderer.esm.js');
|
|
865
|
-
return hookRenderer.reactHooksRenderHook(callback, children => this.
|
|
888
|
+
return hookRenderer.reactHooksRenderHook(callback, children => this.getMockedCompositionRootWithRouter(parentElement ? parentElement(children) : children));
|
|
866
889
|
});
|
|
867
890
|
}
|
|
868
891
|
/**
|
|
@@ -877,7 +900,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
877
900
|
let mountedcomponent;
|
|
878
901
|
yield act(() => __awaiter(this, void 0, void 0, function* () {
|
|
879
902
|
mountedcomponent = render(child, {
|
|
880
|
-
wrapper: ({ children }) => this.
|
|
903
|
+
wrapper: ({ children }) => this.getMockedCompositionRootWithRouter(children),
|
|
881
904
|
});
|
|
882
905
|
yield flushPromises();
|
|
883
906
|
}));
|
|
@@ -894,7 +917,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
894
917
|
* This will return the children in the correct mocked hierarchy of context providers.
|
|
895
918
|
*/
|
|
896
919
|
storybook(child) {
|
|
897
|
-
return this.getMockedCompositionRoot(child,
|
|
920
|
+
return this.getMockedCompositionRoot(child, true);
|
|
898
921
|
}
|
|
899
922
|
}
|
|
900
923
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MockedResponse } from "@apollo/client/testing";
|
|
2
2
|
import { AnyRoute } from "@tanstack/react-router";
|
|
3
3
|
import { RenderResult } from "@testing-library/react";
|
|
4
|
-
import { AssetSortingContextValue, ConfirmationDialogContextValue, FilterBarValues, IAnalyticsContext, ICurrentUserContext, IEnvironmentContext, INavigationContext, IOemBrandingContext, IToastContext, ITokenContext, IUserPreferencesContext, IUserSubscriptionContext, ModalDialogContextValue } from "@trackunit/react-core-contexts-api";
|
|
4
|
+
import { AssetSortingContextValue, ConfirmationDialogContextValue, ErrorHandlingContextValue, 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
6
|
import { MemoryRouterProps } from "./utils/routingUtils";
|
|
7
7
|
/**
|
|
@@ -22,6 +22,7 @@ export declare class TrackunitProvidersMockBuilder<T extends AnyRoute> {
|
|
|
22
22
|
protected selectedRouterProps: MemoryRouterProps<T> | null;
|
|
23
23
|
protected selectedRootRoute: AnyRoute | null;
|
|
24
24
|
protected selectedToastContext: IToastContext;
|
|
25
|
+
protected selectedErrorHandler: ErrorHandlingContextValue;
|
|
25
26
|
protected selectedConfirmationDialogContext: ConfirmationDialogContextValue;
|
|
26
27
|
protected selectedAssetSortingContext: AssetSortingContextValue;
|
|
27
28
|
protected selectedCurrentUserContext: ICurrentUserContext;
|
|
@@ -270,6 +271,10 @@ export declare class TrackunitProvidersMockBuilder<T extends AnyRoute> {
|
|
|
270
271
|
* modalDialog
|
|
271
272
|
*/
|
|
272
273
|
modalDialog(modalDialog: Partial<ModalDialogContextValue>): this;
|
|
274
|
+
/**
|
|
275
|
+
* errorHandler
|
|
276
|
+
*/
|
|
277
|
+
errorHandler(errorHandler: Partial<ErrorHandlingContextValue>): this;
|
|
273
278
|
/**
|
|
274
279
|
* Use this token.
|
|
275
280
|
*
|
|
@@ -353,7 +358,8 @@ export declare class TrackunitProvidersMockBuilder<T extends AnyRoute> {
|
|
|
353
358
|
* @param testChildren - the child element being tested.
|
|
354
359
|
* @param addTestRootContainer - if you want to add a root container to the test.
|
|
355
360
|
*/
|
|
356
|
-
protected getMockedCompositionRoot(testChildren: React.ReactNode,
|
|
361
|
+
protected getMockedCompositionRoot(testChildren: React.ReactNode, forceDebugging?: boolean): JSX.Element;
|
|
362
|
+
protected getMockedCompositionRootWithRouter(testChildren: React.ReactNode, addTestRootContainer?: boolean, forceDebugging?: boolean): JSX.Element;
|
|
357
363
|
/**
|
|
358
364
|
* This will return the mocked composition root.
|
|
359
365
|
*/
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ErrorHandlingContextValue } from "@trackunit/react-core-contexts-api";
|
|
2
|
+
/**
|
|
3
|
+
* Mocks the ErrorHandlingContextValue
|
|
4
|
+
*
|
|
5
|
+
* @returns {ErrorHandlingContextValue} - Returns the mocked current user context
|
|
6
|
+
*/
|
|
7
|
+
export declare const mockErrorHandlerContext: ErrorHandlingContextValue;
|