@trackunit/react-core-contexts-test 0.1.60 → 0.1.61
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/index2.cjs
CHANGED
|
@@ -145,6 +145,11 @@ const mockEnvironmentContext = {
|
|
|
145
145
|
trackunitRestApiUrl: "",
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
+
const mockOemBrandingContext = {
|
|
149
|
+
getOemBranding: doNothing,
|
|
150
|
+
getOemImage: doNothing,
|
|
151
|
+
};
|
|
152
|
+
|
|
148
153
|
const mockToastContext = {
|
|
149
154
|
addToast: doNothing,
|
|
150
155
|
setIsManifestError: doNothing,
|
|
@@ -225,6 +230,7 @@ class MockContextProviderBuilder {
|
|
|
225
230
|
this.selectedAssetSortingContext = mockAssetSortingContext;
|
|
226
231
|
this.selectedCurrentUserContext = mockCurrentUserContext();
|
|
227
232
|
this.selectedAnalyticsContext = mockAnalyticsContext;
|
|
233
|
+
this.selectedOemBrandingContext = mockOemBrandingContext;
|
|
228
234
|
}
|
|
229
235
|
/**
|
|
230
236
|
* Use this Analytics Context.
|
|
@@ -353,6 +359,15 @@ class MockContextProviderBuilder {
|
|
|
353
359
|
this.selectedToastContext = Object.assign(Object.assign({}, mockToastContext), toastContext);
|
|
354
360
|
return this;
|
|
355
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* Set irisOemApp SDK context.
|
|
364
|
+
*
|
|
365
|
+
* @param overrides - Override the default context.
|
|
366
|
+
*/
|
|
367
|
+
oemBrandingContext(overrides) {
|
|
368
|
+
this.selectedOemBrandingContext = Object.assign(Object.assign({}, mockOemBrandingContext), overrides);
|
|
369
|
+
return this;
|
|
370
|
+
}
|
|
356
371
|
/**
|
|
357
372
|
* This will use RTL.render the child in the correct mocked hierarchy of context providers.
|
|
358
373
|
*
|
|
@@ -393,7 +408,7 @@ class MockContextProviderBuilder {
|
|
|
393
408
|
* @param addTestRootContainer - if you want to add a root container to the test.
|
|
394
409
|
*/
|
|
395
410
|
getMockedCompositionRoot(testChildren, addTestRootContainer = true) {
|
|
396
|
-
return (jsxRuntime.jsx(reactCoreHooks.EnvironmentContextProvider, Object.assign({ value: this.selectedEnvironmentContext }, { children: jsxRuntime.jsx(reactRouterDom.MemoryRouter, Object.assign({}, this.selectedRouterProps, { children: jsxRuntime.jsx(reactCoreHooks.CurrentUserProvider, Object.assign({ value: this.selectedCurrentUserContext }, { children: jsxRuntime.jsx(reactCoreHooks.AnalyticsContext.Provider, Object.assign({ value: this.selectedAnalyticsContext }, { children: jsxRuntime.jsx(reactCoreHooks.UserSubscriptionProvider, Object.assign({ value: mockUserSubscriptionProviderValue(this.features, this.userSubscriptionPackageType) }, { children: jsxRuntime.jsx(reactCoreHooks.TokenProvider, Object.assign({ value: this.selectedTokenContext }, { children: jsxRuntime.jsx(reactCoreHooks.ToastProvider, Object.assign({ value: this.selectedToastContext }, { children: jsxRuntime.jsx(reactCoreHooks.GlobalSelectionProvider, Object.assign({ value: this.selectedGlobalSelection }, { children: jsxRuntime.jsx(reactCoreHooks.AssetSortingProvider, Object.assign({ value: this.selectedAssetSortingContext }, { children: jsxRuntime.jsx(ApolloMockedProviderWithError, Object.assign({ mocks: this.selectedApolloMocks, addTypename: false }, { children: addTestRootContainer ? (jsxRuntime.jsx(TestRoot, Object.assign({ "data-testid": "testRoot" }, { children: testChildren }))) : (jsxRuntime.jsx("div", { children: testChildren })) })) })) })) })) })) })) })) })) })) })));
|
|
411
|
+
return (jsxRuntime.jsx(reactCoreHooks.EnvironmentContextProvider, Object.assign({ value: this.selectedEnvironmentContext }, { children: jsxRuntime.jsx(reactRouterDom.MemoryRouter, Object.assign({}, this.selectedRouterProps, { children: jsxRuntime.jsx(reactCoreHooks.CurrentUserProvider, Object.assign({ value: this.selectedCurrentUserContext }, { children: jsxRuntime.jsx(reactCoreHooks.AnalyticsContext.Provider, Object.assign({ value: this.selectedAnalyticsContext }, { children: jsxRuntime.jsx(reactCoreHooks.UserSubscriptionProvider, Object.assign({ value: mockUserSubscriptionProviderValue(this.features, this.userSubscriptionPackageType) }, { children: jsxRuntime.jsx(reactCoreHooks.OemBrandingContextProvider, Object.assign({ value: this.selectedOemBrandingContext }, { children: jsxRuntime.jsx(reactCoreHooks.TokenProvider, Object.assign({ value: this.selectedTokenContext }, { children: jsxRuntime.jsx(reactCoreHooks.ToastProvider, Object.assign({ value: this.selectedToastContext }, { children: jsxRuntime.jsx(reactCoreHooks.GlobalSelectionProvider, Object.assign({ value: this.selectedGlobalSelection }, { children: jsxRuntime.jsx(reactCoreHooks.AssetSortingProvider, Object.assign({ value: this.selectedAssetSortingContext }, { children: jsxRuntime.jsx(ApolloMockedProviderWithError, Object.assign({ mocks: this.selectedApolloMocks, addTypename: false }, { children: addTestRootContainer ? (jsxRuntime.jsx(TestRoot, Object.assign({ "data-testid": "testRoot" }, { children: testChildren }))) : (jsxRuntime.jsx("div", { children: testChildren })) })) })) })) })) })) })) })) })) })) })) })));
|
|
397
412
|
}
|
|
398
413
|
}
|
|
399
414
|
/**
|
package/index2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { act, render } from '@testing-library/react';
|
|
3
3
|
import { AssetSortByProperty, SortOrder, UserSubscriptionPackage } from '@trackunit/react-core-contexts-api';
|
|
4
|
-
import { EnvironmentContextProvider, CurrentUserProvider, AnalyticsContext, UserSubscriptionProvider, TokenProvider, ToastProvider, GlobalSelectionProvider, AssetSortingProvider } from '@trackunit/react-core-hooks';
|
|
4
|
+
import { EnvironmentContextProvider, CurrentUserProvider, AnalyticsContext, UserSubscriptionProvider, OemBrandingContextProvider, TokenProvider, ToastProvider, GlobalSelectionProvider, AssetSortingProvider } from '@trackunit/react-core-hooks';
|
|
5
5
|
import { tw } from '@trackunit/tailwind-styled-components';
|
|
6
6
|
import { MemoryRouter } from 'react-router-dom';
|
|
7
7
|
import { ApolloLink } from '@apollo/client';
|
|
@@ -143,6 +143,11 @@ const mockEnvironmentContext = {
|
|
|
143
143
|
trackunitRestApiUrl: "",
|
|
144
144
|
};
|
|
145
145
|
|
|
146
|
+
const mockOemBrandingContext = {
|
|
147
|
+
getOemBranding: doNothing,
|
|
148
|
+
getOemImage: doNothing,
|
|
149
|
+
};
|
|
150
|
+
|
|
146
151
|
const mockToastContext = {
|
|
147
152
|
addToast: doNothing,
|
|
148
153
|
setIsManifestError: doNothing,
|
|
@@ -223,6 +228,7 @@ class MockContextProviderBuilder {
|
|
|
223
228
|
this.selectedAssetSortingContext = mockAssetSortingContext;
|
|
224
229
|
this.selectedCurrentUserContext = mockCurrentUserContext();
|
|
225
230
|
this.selectedAnalyticsContext = mockAnalyticsContext;
|
|
231
|
+
this.selectedOemBrandingContext = mockOemBrandingContext;
|
|
226
232
|
}
|
|
227
233
|
/**
|
|
228
234
|
* Use this Analytics Context.
|
|
@@ -351,6 +357,15 @@ class MockContextProviderBuilder {
|
|
|
351
357
|
this.selectedToastContext = Object.assign(Object.assign({}, mockToastContext), toastContext);
|
|
352
358
|
return this;
|
|
353
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Set irisOemApp SDK context.
|
|
362
|
+
*
|
|
363
|
+
* @param overrides - Override the default context.
|
|
364
|
+
*/
|
|
365
|
+
oemBrandingContext(overrides) {
|
|
366
|
+
this.selectedOemBrandingContext = Object.assign(Object.assign({}, mockOemBrandingContext), overrides);
|
|
367
|
+
return this;
|
|
368
|
+
}
|
|
354
369
|
/**
|
|
355
370
|
* This will use RTL.render the child in the correct mocked hierarchy of context providers.
|
|
356
371
|
*
|
|
@@ -391,7 +406,7 @@ class MockContextProviderBuilder {
|
|
|
391
406
|
* @param addTestRootContainer - if you want to add a root container to the test.
|
|
392
407
|
*/
|
|
393
408
|
getMockedCompositionRoot(testChildren, addTestRootContainer = true) {
|
|
394
|
-
return (jsx(EnvironmentContextProvider, Object.assign({ value: this.selectedEnvironmentContext }, { children: jsx(MemoryRouter, Object.assign({}, this.selectedRouterProps, { children: jsx(CurrentUserProvider, Object.assign({ value: this.selectedCurrentUserContext }, { children: jsx(AnalyticsContext.Provider, Object.assign({ value: this.selectedAnalyticsContext }, { children: jsx(UserSubscriptionProvider, Object.assign({ value: mockUserSubscriptionProviderValue(this.features, this.userSubscriptionPackageType) }, { children: jsx(TokenProvider, Object.assign({ value: this.selectedTokenContext }, { children: jsx(ToastProvider, Object.assign({ value: this.selectedToastContext }, { children: jsx(GlobalSelectionProvider, Object.assign({ value: this.selectedGlobalSelection }, { children: jsx(AssetSortingProvider, Object.assign({ value: this.selectedAssetSortingContext }, { children: jsx(ApolloMockedProviderWithError, Object.assign({ mocks: this.selectedApolloMocks, addTypename: false }, { children: addTestRootContainer ? (jsx(TestRoot, Object.assign({ "data-testid": "testRoot" }, { children: testChildren }))) : (jsx("div", { children: testChildren })) })) })) })) })) })) })) })) })) })) })));
|
|
409
|
+
return (jsx(EnvironmentContextProvider, Object.assign({ value: this.selectedEnvironmentContext }, { children: jsx(MemoryRouter, Object.assign({}, this.selectedRouterProps, { children: jsx(CurrentUserProvider, Object.assign({ value: this.selectedCurrentUserContext }, { children: jsx(AnalyticsContext.Provider, Object.assign({ value: this.selectedAnalyticsContext }, { children: jsx(UserSubscriptionProvider, Object.assign({ value: mockUserSubscriptionProviderValue(this.features, this.userSubscriptionPackageType) }, { children: jsx(OemBrandingContextProvider, Object.assign({ value: this.selectedOemBrandingContext }, { children: jsx(TokenProvider, Object.assign({ value: this.selectedTokenContext }, { children: jsx(ToastProvider, Object.assign({ value: this.selectedToastContext }, { children: jsx(GlobalSelectionProvider, Object.assign({ value: this.selectedGlobalSelection }, { children: jsx(AssetSortingProvider, Object.assign({ value: this.selectedAssetSortingContext }, { children: jsx(ApolloMockedProviderWithError, Object.assign({ mocks: this.selectedApolloMocks, addTypename: false }, { children: addTestRootContainer ? (jsx(TestRoot, Object.assign({ "data-testid": "testRoot" }, { children: testChildren }))) : (jsx("div", { children: testChildren })) })) })) })) })) })) })) })) })) })) })) })));
|
|
395
410
|
}
|
|
396
411
|
}
|
|
397
412
|
/**
|
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.61",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"types": "./src/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@apollo/client": "3.7.10",
|
|
12
|
-
"@trackunit/react-core-contexts-api": "0.2.
|
|
13
|
-
"@trackunit/react-core-hooks": "0.2.
|
|
12
|
+
"@trackunit/react-core-contexts-api": "0.2.34",
|
|
13
|
+
"@trackunit/react-core-hooks": "0.2.56",
|
|
14
14
|
"@trackunit/tailwind-styled-components": "0.0.56",
|
|
15
15
|
"graphql": "15.8.0",
|
|
16
16
|
"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 { IAnalyticsContext, IAssetSortingContext, ICurrentUserContext, IEnvironmentContext, IFeature, IGlobalSelectionContext, IToastContext, ITokenContext, UserSubscriptionPackageType } from "@trackunit/react-core-contexts-api";
|
|
3
|
+
import { IAnalyticsContext, IAssetSortingContext, ICurrentUserContext, IEnvironmentContext, IFeature, IGlobalSelectionContext, IOemBrandingContext, IToastContext, ITokenContext, UserSubscriptionPackageType } from "@trackunit/react-core-contexts-api";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { MemoryRouterProps } from "react-router-dom";
|
|
6
6
|
/**
|
|
@@ -20,6 +20,7 @@ export declare class MockContextProviderBuilder {
|
|
|
20
20
|
protected selectedAssetSortingContext: IAssetSortingContext;
|
|
21
21
|
protected selectedCurrentUserContext: ICurrentUserContext;
|
|
22
22
|
protected selectedAnalyticsContext: IAnalyticsContext<{}>;
|
|
23
|
+
protected selectedOemBrandingContext: IOemBrandingContext;
|
|
23
24
|
/**
|
|
24
25
|
* Use this Analytics Context.
|
|
25
26
|
*
|
|
@@ -98,6 +99,12 @@ export declare class MockContextProviderBuilder {
|
|
|
98
99
|
* @param toastContext - Override the default toast context.
|
|
99
100
|
*/
|
|
100
101
|
toast(toastContext?: Partial<IToastContext>): this;
|
|
102
|
+
/**
|
|
103
|
+
* Set irisOemApp SDK context.
|
|
104
|
+
*
|
|
105
|
+
* @param overrides - Override the default context.
|
|
106
|
+
*/
|
|
107
|
+
oemBrandingContext(overrides: Partial<IOemBrandingContext>): this;
|
|
101
108
|
/**
|
|
102
109
|
* This will use RTL.render the child in the correct mocked hierarchy of context providers.
|
|
103
110
|
*
|