@trackunit/react-core-contexts-test 1.9.12 → 1.9.15

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
@@ -14125,31 +14125,15 @@ class TrackunitProvidersMockBuilder {
14125
14125
  this.selectedTokenContext = { token };
14126
14126
  return this;
14127
14127
  }
14128
+ // Implementation
14128
14129
  /**
14129
- * Use this Router Props with the given mocks.
14130
- *
14131
- * This is used to provide a MemoryRouter from lib "@tanstack/react-router"
14132
- *
14133
- * @example
14134
- * ...
14135
- * it("should allow render", async () => {
14136
- * await trackunitProviders().routerProps(yourRouterPropsMock).render(<YourTestComponent data-testid="yourTestId" />);
14137
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
14138
- * });
14139
- * ...
14140
- * @example
14141
- * ...
14142
- * it("should allow renderHook", async () => {
14143
- * const { result } = await trackunitProviders().routerProps(yourRouterPropsMock).renderHook(() => useYourTestHook());
14144
- * expect(result.current).toEqual(anything());
14145
- * });
14146
- * ...
14147
14130
  * @param routerProps - The router props to use.
14148
- * @returns { TrackunitProvidersMockBuilder } - The builder.
14131
+ * @returns { TrackunitProvidersMockBuilder } - The builder instance for chaining.
14149
14132
  */
14150
14133
  routerProps(routerProps) {
14151
14134
  this.selectedRouterProps = routerProps;
14152
- return this.rootRoute(routerProps.routeTree ? routerProps.routeTree : this.selectedRootRoute);
14135
+ this.rootRoute(routerProps.routeTree ? routerProps.routeTree : this.selectedRootRoute);
14136
+ return this;
14153
14137
  }
14154
14138
  /**
14155
14139
  * Use this Manager Apollo Context Provider with the given mocks.
package/index.esm2.js CHANGED
@@ -14103,31 +14103,15 @@ class TrackunitProvidersMockBuilder {
14103
14103
  this.selectedTokenContext = { token };
14104
14104
  return this;
14105
14105
  }
14106
+ // Implementation
14106
14107
  /**
14107
- * Use this Router Props with the given mocks.
14108
- *
14109
- * This is used to provide a MemoryRouter from lib "@tanstack/react-router"
14110
- *
14111
- * @example
14112
- * ...
14113
- * it("should allow render", async () => {
14114
- * await trackunitProviders().routerProps(yourRouterPropsMock).render(<YourTestComponent data-testid="yourTestId" />);
14115
- * expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
14116
- * });
14117
- * ...
14118
- * @example
14119
- * ...
14120
- * it("should allow renderHook", async () => {
14121
- * const { result } = await trackunitProviders().routerProps(yourRouterPropsMock).renderHook(() => useYourTestHook());
14122
- * expect(result.current).toEqual(anything());
14123
- * });
14124
- * ...
14125
14108
  * @param routerProps - The router props to use.
14126
- * @returns { TrackunitProvidersMockBuilder } - The builder.
14109
+ * @returns { TrackunitProvidersMockBuilder } - The builder instance for chaining.
14127
14110
  */
14128
14111
  routerProps(routerProps) {
14129
14112
  this.selectedRouterProps = routerProps;
14130
- return this.rootRoute(routerProps.routeTree ? routerProps.routeTree : this.selectedRootRoute);
14113
+ this.rootRoute(routerProps.routeTree ? routerProps.routeTree : this.selectedRootRoute);
14114
+ return this;
14131
14115
  }
14132
14116
  /**
14133
14117
  * Use this Manager Apollo Context Provider with the given mocks.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts-test",
3
- "version": "1.9.12",
3
+ "version": "1.9.15",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -10,11 +10,11 @@
10
10
  "@apollo/client": "3.13.8",
11
11
  "react": "19.0.0",
12
12
  "@tanstack/react-router": "1.114.29",
13
- "@trackunit/shared-utils": "1.11.9",
13
+ "@trackunit/shared-utils": "1.11.12",
14
14
  "graphql": "^16.10.0",
15
15
  "@tanstack/router-core": "1.114.29",
16
- "@trackunit/iris-app-runtime-core-api": "1.9.12",
17
- "@trackunit/react-core-contexts-api": "1.10.12",
16
+ "@trackunit/iris-app-runtime-core-api": "1.9.15",
17
+ "@trackunit/react-core-contexts-api": "1.10.15",
18
18
  "es-toolkit": "^1.39.10"
19
19
  },
20
20
  "module": "./index.esm.js",
@@ -1,5 +1,5 @@
1
1
  import { MockedResponse } from "@apollo/client/testing";
2
- import { AnyRoute } from "@tanstack/react-router";
2
+ import { AnyRoute, RegisteredRouter } from "@tanstack/react-router";
3
3
  import { RenderResult } from "@testing-library/react";
4
4
  import { AnalyticsRuntimeApiSync, AssetSortingState, ConfirmationDialogRuntimeApi, CurrentUserPreferenceState, CurrentUserState, EnvironmentState, ErrorHandlingContextValue, FilterBarContext, ITokenContext, ModalDialogRuntimeApi, NavigationRuntimeApi, OemBrandingRuntimeApi, TimeRangeContext, UserSubscription, WidgetConfigContext } from "@trackunit/iris-app-runtime-core-api";
5
5
  import { ExportDataContextState, IToastContext } from "@trackunit/react-core-contexts-api";
@@ -14,7 +14,7 @@ import { MemoryRouterProps } from "./utils/routingUtils";
14
14
  * For Storybook:
15
15
  * - storybook
16
16
  */
17
- export declare class TrackunitProvidersMockBuilder<T extends AnyRoute> {
17
+ export declare class TrackunitProvidersMockBuilder<TRouterTree extends AnyRoute> {
18
18
  protected selectedEnvironmentContext: EnvironmentState;
19
19
  protected selectedModalDialogContext: ModalDialogRuntimeApi;
20
20
  protected selectedTimeRangeContext: TimeRangeContext;
@@ -22,7 +22,7 @@ export declare class TrackunitProvidersMockBuilder<T extends AnyRoute> {
22
22
  protected selectedNavigationContext: NavigationRuntimeApi;
23
23
  protected selectedTokenContext: ITokenContext;
24
24
  protected selectedApolloMocks: Array<MockedResponse>;
25
- protected selectedRouterProps: MemoryRouterProps<T> | null;
25
+ protected selectedRouterProps: MemoryRouterProps<TRouterTree> | null;
26
26
  protected selectedRootRoute: AnyRoute | null;
27
27
  protected selectedToastContext: IToastContext;
28
28
  protected selectedErrorHandler: ErrorHandlingContextValue;
@@ -354,7 +354,16 @@ export declare class TrackunitProvidersMockBuilder<T extends AnyRoute> {
354
354
  * @param routerProps - The router props to use.
355
355
  * @returns { TrackunitProvidersMockBuilder } - The builder.
356
356
  */
357
- routerProps(routerProps: MemoryRouterProps<T>): this;
357
+ routerProps<TRoute extends AnyRoute>(routerProps: MemoryRouterProps<TRoute> & {
358
+ routeTree: TRoute;
359
+ }): this;
360
+ /**
361
+ * @param routerProps - The router props to use.
362
+ * @returns The builder instance for chaining.
363
+ */
364
+ routerProps(routerProps: Omit<MemoryRouterProps<RegisteredRouter["routeTree"]>, "routeTree"> & {
365
+ routeTree?: undefined;
366
+ }): this;
358
367
  /**
359
368
  * Use this Manager Apollo Context Provider with the given mocks.
360
369
  *
@@ -1,9 +1,9 @@
1
1
  import { AnyRoute, RegisteredRouter, RouteIds } from "@tanstack/react-router";
2
2
  import { ReactElement, ReactNode } from "react";
3
- export type MemoryRouterProps<T extends AnyRoute> = {
4
- routeTree?: T;
3
+ export type MemoryRouterProps<TRouterTree extends AnyRoute = RegisteredRouter["routeTree"]> = {
4
+ routeTree?: TRouterTree;
5
5
  initialEntries?: Array<{
6
- route: RouteIds<RegisteredRouter["routeTree"]>;
6
+ route: RouteIds<TRouterTree>;
7
7
  path: string;
8
8
  component?: () => ReactElement | null;
9
9
  beforeLoad?: () => void;