@trackunit/react-core-contexts-test 0.1.150-alpha-bc5b0fcd90.0 → 0.1.150
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 +4 -32
- package/index.esm2.js +5 -33
- package/package.json +1 -1
- package/src/TrackunitProvidersMockBuilder.d.ts +1 -26
package/index.cjs2.js
CHANGED
|
@@ -282,7 +282,6 @@ class TrackunitProvidersMockBuilder {
|
|
|
282
282
|
this.selectedApolloMocks = [];
|
|
283
283
|
this.selectedRouterProps = {};
|
|
284
284
|
this.selectedToastContext = mockToastContext;
|
|
285
|
-
this.selectedGlobalSelection = { selection: null };
|
|
286
285
|
this.selectedAssetSortingContext = mockAssetSortingContext;
|
|
287
286
|
this.selectedCurrentUserContext = mockCurrentUserContext;
|
|
288
287
|
this.selectedCurrentUserPreferenceContext = mockCurrentUserPreferenceContext;
|
|
@@ -560,33 +559,6 @@ class TrackunitProvidersMockBuilder {
|
|
|
560
559
|
this.selectedToastContext = Object.assign(Object.assign({}, mockToastContext), toastContext);
|
|
561
560
|
return this;
|
|
562
561
|
}
|
|
563
|
-
/**
|
|
564
|
-
* Use this global selection.
|
|
565
|
-
* Defaults to null.
|
|
566
|
-
*
|
|
567
|
-
* This context is used by the useGlobalSelection hook from lib "@trackunit/react-core-hooks"
|
|
568
|
-
*
|
|
569
|
-
* @example
|
|
570
|
-
* ...
|
|
571
|
-
* it("should allow render", async () => {
|
|
572
|
-
* await trackunitProviders().globalSelection(yourGlobalSelectionMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
573
|
-
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
574
|
-
* });
|
|
575
|
-
* ...
|
|
576
|
-
* @example
|
|
577
|
-
* ...
|
|
578
|
-
* it("should allow renderHook", async () => {
|
|
579
|
-
* const { result } = await trackunitProviders().globalSelection(yourGlobalSelectionMock).renderHook(() => useYourTestHook());
|
|
580
|
-
* expect(result.current).toEqual(anything());
|
|
581
|
-
* });
|
|
582
|
-
* ...
|
|
583
|
-
* @param globalSelection - The global selection to use.
|
|
584
|
-
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
585
|
-
*/
|
|
586
|
-
globalSelection(globalSelection) {
|
|
587
|
-
this.selectedGlobalSelection = { selection: globalSelection };
|
|
588
|
-
return this;
|
|
589
|
-
}
|
|
590
562
|
/**
|
|
591
563
|
* Use this token.
|
|
592
564
|
*
|
|
@@ -681,10 +653,10 @@ class TrackunitProvidersMockBuilder {
|
|
|
681
653
|
* @param addTestRootContainer - if you want to add a root container to the test.
|
|
682
654
|
*/
|
|
683
655
|
getMockedCompositionRoot(testChildren, addTestRootContainer = true) {
|
|
684
|
-
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.
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
656
|
+
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.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: {
|
|
657
|
+
"--tw-scale-x": "0.99",
|
|
658
|
+
"--tw-scale-y": "0.99",
|
|
659
|
+
}, className: "inline-block h-[1000px] w-[1024px]", "data-testid": "testRoot", children: testChildren })) : (jsxRuntime.jsx("div", { children: testChildren })) }) }) }) }) }) }) }) }) }) }) }) })) }));
|
|
688
660
|
}
|
|
689
661
|
/**
|
|
690
662
|
* This will return the mocked composition root.
|
package/index.esm2.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { act, render } from '@testing-library/react';
|
|
3
|
-
import { EnvironmentContextProvider, CurrentUserProvider, AnalyticsContext, UserSubscriptionProvider, OemBrandingContextProvider, TokenProvider, ToastProvider,
|
|
3
|
+
import { EnvironmentContextProvider, CurrentUserProvider, AnalyticsContext, UserSubscriptionProvider, OemBrandingContextProvider, TokenProvider, ToastProvider, FilterBarProvider, AssetSortingProvider, NavigationContextProvider, CurrentUserPreferenceProvider } from '@trackunit/react-core-hooks';
|
|
4
4
|
import { omit } from 'lodash';
|
|
5
5
|
import { MemoryRouter } from 'react-router-dom';
|
|
6
6
|
import { ApolloLink } from '@apollo/client';
|
|
@@ -276,7 +276,6 @@ class TrackunitProvidersMockBuilder {
|
|
|
276
276
|
this.selectedApolloMocks = [];
|
|
277
277
|
this.selectedRouterProps = {};
|
|
278
278
|
this.selectedToastContext = mockToastContext;
|
|
279
|
-
this.selectedGlobalSelection = { selection: null };
|
|
280
279
|
this.selectedAssetSortingContext = mockAssetSortingContext;
|
|
281
280
|
this.selectedCurrentUserContext = mockCurrentUserContext;
|
|
282
281
|
this.selectedCurrentUserPreferenceContext = mockCurrentUserPreferenceContext;
|
|
@@ -554,33 +553,6 @@ class TrackunitProvidersMockBuilder {
|
|
|
554
553
|
this.selectedToastContext = Object.assign(Object.assign({}, mockToastContext), toastContext);
|
|
555
554
|
return this;
|
|
556
555
|
}
|
|
557
|
-
/**
|
|
558
|
-
* Use this global selection.
|
|
559
|
-
* Defaults to null.
|
|
560
|
-
*
|
|
561
|
-
* This context is used by the useGlobalSelection hook from lib "@trackunit/react-core-hooks"
|
|
562
|
-
*
|
|
563
|
-
* @example
|
|
564
|
-
* ...
|
|
565
|
-
* it("should allow render", async () => {
|
|
566
|
-
* await trackunitProviders().globalSelection(yourGlobalSelectionMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
567
|
-
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
568
|
-
* });
|
|
569
|
-
* ...
|
|
570
|
-
* @example
|
|
571
|
-
* ...
|
|
572
|
-
* it("should allow renderHook", async () => {
|
|
573
|
-
* const { result } = await trackunitProviders().globalSelection(yourGlobalSelectionMock).renderHook(() => useYourTestHook());
|
|
574
|
-
* expect(result.current).toEqual(anything());
|
|
575
|
-
* });
|
|
576
|
-
* ...
|
|
577
|
-
* @param globalSelection - The global selection to use.
|
|
578
|
-
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
579
|
-
*/
|
|
580
|
-
globalSelection(globalSelection) {
|
|
581
|
-
this.selectedGlobalSelection = { selection: globalSelection };
|
|
582
|
-
return this;
|
|
583
|
-
}
|
|
584
556
|
/**
|
|
585
557
|
* Use this token.
|
|
586
558
|
*
|
|
@@ -675,10 +647,10 @@ class TrackunitProvidersMockBuilder {
|
|
|
675
647
|
* @param addTestRootContainer - if you want to add a root container to the test.
|
|
676
648
|
*/
|
|
677
649
|
getMockedCompositionRoot(testChildren, addTestRootContainer = true) {
|
|
678
|
-
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(
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
650
|
+
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(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: {
|
|
651
|
+
"--tw-scale-x": "0.99",
|
|
652
|
+
"--tw-scale-y": "0.99",
|
|
653
|
+
}, className: "inline-block h-[1000px] w-[1024px]", "data-testid": "testRoot", children: testChildren })) : (jsx("div", { children: testChildren })) }) }) }) }) }) }) }) }) }) }) }) })) }));
|
|
682
654
|
}
|
|
683
655
|
/**
|
|
684
656
|
* This will return the mocked composition root.
|
package/package.json
CHANGED
|
@@ -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,
|
|
3
|
+
import { FilterBarValues, IAnalyticsContext, IAssetSortingContext, ICurrentUserContext, IEnvironmentContext, 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
|
/**
|
|
@@ -19,7 +19,6 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
19
19
|
protected selectedApolloMocks: MockedResponse[];
|
|
20
20
|
protected selectedRouterProps: MemoryRouterProps;
|
|
21
21
|
protected selectedToastContext: IToastContext;
|
|
22
|
-
protected selectedGlobalSelection: IGlobalSelectionContext;
|
|
23
22
|
protected selectedAssetSortingContext: IAssetSortingContext;
|
|
24
23
|
protected selectedCurrentUserContext: ICurrentUserContext;
|
|
25
24
|
protected selectedCurrentUserPreferenceContext: IUserPreferencesContext;
|
|
@@ -259,30 +258,6 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
259
258
|
* @param toastContext - Override the default toast context.
|
|
260
259
|
*/
|
|
261
260
|
toast(toastContext: Partial<IToastContext>): this;
|
|
262
|
-
/**
|
|
263
|
-
* Use this global selection.
|
|
264
|
-
* Defaults to null.
|
|
265
|
-
*
|
|
266
|
-
* This context is used by the useGlobalSelection hook from lib "@trackunit/react-core-hooks"
|
|
267
|
-
*
|
|
268
|
-
* @example
|
|
269
|
-
* ...
|
|
270
|
-
* it("should allow render", async () => {
|
|
271
|
-
* await trackunitProviders().globalSelection(yourGlobalSelectionMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
272
|
-
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
273
|
-
* });
|
|
274
|
-
* ...
|
|
275
|
-
* @example
|
|
276
|
-
* ...
|
|
277
|
-
* it("should allow renderHook", async () => {
|
|
278
|
-
* const { result } = await trackunitProviders().globalSelection(yourGlobalSelectionMock).renderHook(() => useYourTestHook());
|
|
279
|
-
* expect(result.current).toEqual(anything());
|
|
280
|
-
* });
|
|
281
|
-
* ...
|
|
282
|
-
* @param globalSelection - The global selection to use.
|
|
283
|
-
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
284
|
-
*/
|
|
285
|
-
globalSelection(globalSelection: IGlobalSelectionContext["selection"]): this;
|
|
286
261
|
/**
|
|
287
262
|
* Use this token.
|
|
288
263
|
*
|