@trackunit/react-core-contexts-test 0.1.124 → 0.1.126
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/index.cjs2.js
CHANGED
|
@@ -43382,6 +43382,21 @@ const mockEnvironmentContext = {
|
|
|
43382
43382
|
hubspotRequestAppAccessFormId: "",
|
|
43383
43383
|
};
|
|
43384
43384
|
|
|
43385
|
+
const mockNavigationContext = {
|
|
43386
|
+
gotoAssetHome: (assetId, options) => {
|
|
43387
|
+
return Promise.resolve(true);
|
|
43388
|
+
},
|
|
43389
|
+
gotoSiteHome: (siteId, options) => {
|
|
43390
|
+
return Promise.resolve(true);
|
|
43391
|
+
},
|
|
43392
|
+
gotoAppLibrary: (irisAppId) => {
|
|
43393
|
+
return Promise.resolve(true);
|
|
43394
|
+
},
|
|
43395
|
+
gotoFleetApp: (options) => {
|
|
43396
|
+
return Promise.resolve(true);
|
|
43397
|
+
},
|
|
43398
|
+
};
|
|
43399
|
+
|
|
43385
43400
|
const mockOemBrandingContext = {
|
|
43386
43401
|
getAllBrandingDetails: doNothing,
|
|
43387
43402
|
getOemBranding: doNothing,
|
|
@@ -43458,6 +43473,7 @@ const flushPromisesInAct = (waitTimeInMS = 0) => {
|
|
|
43458
43473
|
class TrackunitProvidersMockBuilder {
|
|
43459
43474
|
constructor() {
|
|
43460
43475
|
this.selectedEnvironmentContext = mockEnvironmentContext;
|
|
43476
|
+
this.selectedNavigationContext = mockNavigationContext;
|
|
43461
43477
|
this.selectedTokenContext = { token: "fakeToken" };
|
|
43462
43478
|
this.selectedApolloMocks = [];
|
|
43463
43479
|
this.selectedRouterProps = {};
|
|
@@ -43528,6 +43544,22 @@ class TrackunitProvidersMockBuilder {
|
|
|
43528
43544
|
this.selectedEnvironmentContext = Object.assign(Object.assign({}, mockEnvironmentContext), environmentContext);
|
|
43529
43545
|
return this;
|
|
43530
43546
|
}
|
|
43547
|
+
/**
|
|
43548
|
+
* Use this Navigation Context.
|
|
43549
|
+
* Defaults to mockNavigationContext.
|
|
43550
|
+
*
|
|
43551
|
+
* @see mockNavigationContext
|
|
43552
|
+
* @example
|
|
43553
|
+
* ...
|
|
43554
|
+
* it("should allow render", async () => {
|
|
43555
|
+
* await trackunitProviders().navigation(yourPartialNavigationMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
43556
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
43557
|
+
* });
|
|
43558
|
+
*/
|
|
43559
|
+
navigation(navigationContext) {
|
|
43560
|
+
this.selectedNavigationContext = Object.assign(Object.assign({}, mockNavigationContext), navigationContext);
|
|
43561
|
+
return this;
|
|
43562
|
+
}
|
|
43531
43563
|
/**
|
|
43532
43564
|
* Use this to pass in a differerent current user.
|
|
43533
43565
|
* Defaults to mockCurrentUserContext.
|
|
@@ -43845,10 +43877,10 @@ class TrackunitProvidersMockBuilder {
|
|
|
43845
43877
|
* @param addTestRootContainer - if you want to add a root container to the test.
|
|
43846
43878
|
*/
|
|
43847
43879
|
getMockedCompositionRoot(testChildren, addTestRootContainer = true) {
|
|
43848
|
-
return (jsxRuntime.jsx(reactCoreHooks.EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsxRuntime.jsx(reactRouterDom.MemoryRouter, Object.assign({}, this.selectedRouterProps, { 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.GlobalSelectionProvider, { value: this.selectedGlobalSelection, children: jsxRuntime.jsx(reactCoreHooks.FilterBarProvider, { value: { filterBarValues: this.selectedFilterBarValues }, children: jsxRuntime.jsx(reactCoreHooks.AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsxRuntime.jsx(ApolloMockedProviderWithError, { mocks: this.selectedApolloMocks, addTypename: false, children: jsxRuntime.jsx(reactCoreHooks.CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: addTestRootContainer ? (jsxRuntime.jsx("div", { style: {
|
|
43849
|
-
|
|
43850
|
-
|
|
43851
|
-
|
|
43880
|
+
return (jsxRuntime.jsx(reactCoreHooks.EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsxRuntime.jsx(reactRouterDom.MemoryRouter, Object.assign({}, this.selectedRouterProps, { 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.GlobalSelectionProvider, { value: this.selectedGlobalSelection, children: jsxRuntime.jsx(reactCoreHooks.FilterBarProvider, { value: { filterBarValues: this.selectedFilterBarValues }, children: jsxRuntime.jsx(reactCoreHooks.AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsxRuntime.jsx(ApolloMockedProviderWithError, { mocks: this.selectedApolloMocks, addTypename: false, children: jsxRuntime.jsx(reactCoreHooks.NavigationContextProvider, { value: this.selectedNavigationContext, children: jsxRuntime.jsx(reactCoreHooks.CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: addTestRootContainer ? (jsxRuntime.jsx("div", { style: {
|
|
43881
|
+
"--tw-scale-x": "0.99",
|
|
43882
|
+
"--tw-scale-y": "0.99",
|
|
43883
|
+
}, className: "inline-block h-[1000px] w-[1024px]", "data-testid": "testRoot", children: testChildren })) : (jsxRuntime.jsx("div", { children: testChildren })) }) }) }) }) }) }) }) }) }) }) }) }) })) }));
|
|
43852
43884
|
}
|
|
43853
43885
|
/**
|
|
43854
43886
|
* This will return the mocked composition root.
|
package/index.esm2.js
CHANGED
|
@@ -5,7 +5,7 @@ import React__default, { useRef, useMemo, useEffect } from 'react';
|
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
6
|
import * as ReactDOMClient from 'react-dom/client';
|
|
7
7
|
import require$$0 from 'util';
|
|
8
|
-
import { EnvironmentContextProvider, CurrentUserProvider, AnalyticsContext, UserSubscriptionProvider, OemBrandingContextProvider, TokenProvider, ToastProvider, GlobalSelectionProvider, FilterBarProvider, AssetSortingProvider, CurrentUserPreferenceProvider } from '@trackunit/react-core-hooks';
|
|
8
|
+
import { EnvironmentContextProvider, CurrentUserProvider, AnalyticsContext, UserSubscriptionProvider, OemBrandingContextProvider, TokenProvider, ToastProvider, GlobalSelectionProvider, FilterBarProvider, AssetSortingProvider, NavigationContextProvider, CurrentUserPreferenceProvider } from '@trackunit/react-core-hooks';
|
|
9
9
|
import { MemoryRouter } from 'react-router-dom';
|
|
10
10
|
import { AssetSortByProperty, SortOrder } from '@trackunit/react-core-contexts-api';
|
|
11
11
|
|
|
@@ -43354,6 +43354,21 @@ const mockEnvironmentContext = {
|
|
|
43354
43354
|
hubspotRequestAppAccessFormId: "",
|
|
43355
43355
|
};
|
|
43356
43356
|
|
|
43357
|
+
const mockNavigationContext = {
|
|
43358
|
+
gotoAssetHome: (assetId, options) => {
|
|
43359
|
+
return Promise.resolve(true);
|
|
43360
|
+
},
|
|
43361
|
+
gotoSiteHome: (siteId, options) => {
|
|
43362
|
+
return Promise.resolve(true);
|
|
43363
|
+
},
|
|
43364
|
+
gotoAppLibrary: (irisAppId) => {
|
|
43365
|
+
return Promise.resolve(true);
|
|
43366
|
+
},
|
|
43367
|
+
gotoFleetApp: (options) => {
|
|
43368
|
+
return Promise.resolve(true);
|
|
43369
|
+
},
|
|
43370
|
+
};
|
|
43371
|
+
|
|
43357
43372
|
const mockOemBrandingContext = {
|
|
43358
43373
|
getAllBrandingDetails: doNothing,
|
|
43359
43374
|
getOemBranding: doNothing,
|
|
@@ -43430,6 +43445,7 @@ const flushPromisesInAct = (waitTimeInMS = 0) => {
|
|
|
43430
43445
|
class TrackunitProvidersMockBuilder {
|
|
43431
43446
|
constructor() {
|
|
43432
43447
|
this.selectedEnvironmentContext = mockEnvironmentContext;
|
|
43448
|
+
this.selectedNavigationContext = mockNavigationContext;
|
|
43433
43449
|
this.selectedTokenContext = { token: "fakeToken" };
|
|
43434
43450
|
this.selectedApolloMocks = [];
|
|
43435
43451
|
this.selectedRouterProps = {};
|
|
@@ -43500,6 +43516,22 @@ class TrackunitProvidersMockBuilder {
|
|
|
43500
43516
|
this.selectedEnvironmentContext = Object.assign(Object.assign({}, mockEnvironmentContext), environmentContext);
|
|
43501
43517
|
return this;
|
|
43502
43518
|
}
|
|
43519
|
+
/**
|
|
43520
|
+
* Use this Navigation Context.
|
|
43521
|
+
* Defaults to mockNavigationContext.
|
|
43522
|
+
*
|
|
43523
|
+
* @see mockNavigationContext
|
|
43524
|
+
* @example
|
|
43525
|
+
* ...
|
|
43526
|
+
* it("should allow render", async () => {
|
|
43527
|
+
* await trackunitProviders().navigation(yourPartialNavigationMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
43528
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
43529
|
+
* });
|
|
43530
|
+
*/
|
|
43531
|
+
navigation(navigationContext) {
|
|
43532
|
+
this.selectedNavigationContext = Object.assign(Object.assign({}, mockNavigationContext), navigationContext);
|
|
43533
|
+
return this;
|
|
43534
|
+
}
|
|
43503
43535
|
/**
|
|
43504
43536
|
* Use this to pass in a differerent current user.
|
|
43505
43537
|
* Defaults to mockCurrentUserContext.
|
|
@@ -43817,10 +43849,10 @@ class TrackunitProvidersMockBuilder {
|
|
|
43817
43849
|
* @param addTestRootContainer - if you want to add a root container to the test.
|
|
43818
43850
|
*/
|
|
43819
43851
|
getMockedCompositionRoot(testChildren, addTestRootContainer = true) {
|
|
43820
|
-
return (jsx(EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsx(MemoryRouter, Object.assign({}, this.selectedRouterProps, { 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(GlobalSelectionProvider, { value: this.selectedGlobalSelection, children: jsx(FilterBarProvider, { value: { filterBarValues: this.selectedFilterBarValues }, children: jsx(AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsx(ApolloMockedProviderWithError, { mocks: this.selectedApolloMocks, addTypename: false, children: jsx(CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: addTestRootContainer ? (jsx("div", { style: {
|
|
43821
|
-
|
|
43822
|
-
|
|
43823
|
-
|
|
43852
|
+
return (jsx(EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsx(MemoryRouter, Object.assign({}, this.selectedRouterProps, { 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(GlobalSelectionProvider, { value: this.selectedGlobalSelection, children: jsx(FilterBarProvider, { value: { filterBarValues: this.selectedFilterBarValues }, children: jsx(AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsx(ApolloMockedProviderWithError, { mocks: this.selectedApolloMocks, addTypename: false, children: jsx(NavigationContextProvider, { value: this.selectedNavigationContext, children: jsx(CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: addTestRootContainer ? (jsx("div", { style: {
|
|
43853
|
+
"--tw-scale-x": "0.99",
|
|
43854
|
+
"--tw-scale-y": "0.99",
|
|
43855
|
+
}, className: "inline-block h-[1000px] w-[1024px]", "data-testid": "testRoot", children: testChildren })) : (jsx("div", { children: testChildren })) }) }) }) }) }) }) }) }) }) }) }) }) })) }));
|
|
43824
43856
|
}
|
|
43825
43857
|
/**
|
|
43826
43858
|
* This will return the mocked composition root.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-core-contexts-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.126",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"main": "./index.cjs.js",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@apollo/client": "3.7.10",
|
|
13
|
-
"@trackunit/react-core-contexts-api": "0.2.
|
|
14
|
-
"@trackunit/react-core-hooks": "0.2.
|
|
13
|
+
"@trackunit/react-core-contexts-api": "0.2.69",
|
|
14
|
+
"@trackunit/react-core-hooks": "0.2.111",
|
|
15
15
|
"graphql": "15.8.0",
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
17
|
"react": "18.2.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MockedResponse } from "@apollo/client/testing";
|
|
2
2
|
import { RenderResult } from "@testing-library/react";
|
|
3
|
-
import { FilterBarValues, IAnalyticsContext, IAssetSortingContext, ICurrentUserContext, IEnvironmentContext, IGlobalSelectionContext, IOemBrandingContext, IToastContext, ITokenContext, IUserPreferencesContext, IUserSubscriptionContext } from "@trackunit/react-core-contexts-api";
|
|
3
|
+
import { FilterBarValues, IAnalyticsContext, IAssetSortingContext, ICurrentUserContext, IEnvironmentContext, IGlobalSelectionContext, INavigationContext, IOemBrandingContext, IToastContext, ITokenContext, IUserPreferencesContext, IUserSubscriptionContext } from "@trackunit/react-core-contexts-api";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { MemoryRouterProps } from "react-router-dom";
|
|
6
6
|
/**
|
|
@@ -14,6 +14,7 @@ import { MemoryRouterProps } from "react-router-dom";
|
|
|
14
14
|
*/
|
|
15
15
|
export declare class TrackunitProvidersMockBuilder {
|
|
16
16
|
protected selectedEnvironmentContext: IEnvironmentContext;
|
|
17
|
+
protected selectedNavigationContext: INavigationContext;
|
|
17
18
|
protected selectedTokenContext: ITokenContext;
|
|
18
19
|
protected selectedApolloMocks: MockedResponse[];
|
|
19
20
|
protected selectedRouterProps: MemoryRouterProps;
|
|
@@ -76,6 +77,19 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
76
77
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
77
78
|
*/
|
|
78
79
|
environment(environmentContext: Partial<IEnvironmentContext>): this;
|
|
80
|
+
/**
|
|
81
|
+
* Use this Navigation Context.
|
|
82
|
+
* Defaults to mockNavigationContext.
|
|
83
|
+
*
|
|
84
|
+
* @see mockNavigationContext
|
|
85
|
+
* @example
|
|
86
|
+
* ...
|
|
87
|
+
* it("should allow render", async () => {
|
|
88
|
+
* await trackunitProviders().navigation(yourPartialNavigationMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
89
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
90
|
+
* });
|
|
91
|
+
*/
|
|
92
|
+
navigation(navigationContext: Partial<INavigationContext>): this;
|
|
79
93
|
/**
|
|
80
94
|
* Use this to pass in a differerent current user.
|
|
81
95
|
* Defaults to mockCurrentUserContext.
|