@trackunit/react-core-contexts-test 1.11.18 → 1.12.1
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 +25 -19
- package/index.esm2.js +25 -19
- package/package.json +4 -4
- package/src/useDebugger.d.ts +9 -7
- package/src/utils/queryFor.d.ts +8 -6
- package/src/utils/routingUtils.d.ts +11 -9
package/index.cjs2.js
CHANGED
|
@@ -13548,9 +13548,10 @@ const RootRouteDebugger = () => {
|
|
|
13548
13548
|
/**
|
|
13549
13549
|
* This component is used to wrap the children of the RouterContainer to add a test root container.
|
|
13550
13550
|
*
|
|
13551
|
-
* @param
|
|
13552
|
-
* @param
|
|
13553
|
-
* @
|
|
13551
|
+
* @param props - The component props.
|
|
13552
|
+
* @param props.addTestRootContainer - Boolean to add test root container.
|
|
13553
|
+
* @param props.children - Children to be wrapped.
|
|
13554
|
+
* @returns {ReactNode} Children component wrapped in a test root container.
|
|
13554
13555
|
*/
|
|
13555
13556
|
const TestRenderChildren = ({ addTestRootContainer, children }) => {
|
|
13556
13557
|
return addTestRootContainer ? (jsxRuntime.jsx("div", { className: "inline-block h-[1000px] w-[1024px] scale-[.99]", "data-testid": "testRoot", style: {
|
|
@@ -13561,11 +13562,12 @@ const TestRenderChildren = ({ addTestRootContainer, children }) => {
|
|
|
13561
13562
|
/**
|
|
13562
13563
|
* This component is used to wrap the children of the RouterContainer to add a test root container.
|
|
13563
13564
|
*
|
|
13564
|
-
* @param
|
|
13565
|
-
* @param
|
|
13566
|
-
* @param
|
|
13567
|
-
* @param
|
|
13568
|
-
* @
|
|
13565
|
+
* @param props - The component props.
|
|
13566
|
+
* @param props.addTestRootContainer - Boolean to add test root container.
|
|
13567
|
+
* @param props.selectedRouterProps - Selected router props.
|
|
13568
|
+
* @param props.rootRoute - Root route.
|
|
13569
|
+
* @param props.children - Children to be wrapped.
|
|
13570
|
+
* @returns {ReactElement} Children component wrapped in a test root container.
|
|
13569
13571
|
*/
|
|
13570
13572
|
const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute, children, }) => {
|
|
13571
13573
|
const client = react.useApolloClient();
|
|
@@ -14291,8 +14293,8 @@ const useIsFirstRender = () => {
|
|
|
14291
14293
|
* This is a hook version of the class component lifecycle method `componentDidUpdate`.
|
|
14292
14294
|
* ALWAYS wrap in your own object.
|
|
14293
14295
|
*
|
|
14294
|
-
* @param id optional id to use for logging or it will guess the id from the stack trace
|
|
14295
14296
|
* @param propsToWatch all the props to watch for changes
|
|
14297
|
+
* @param id optional id to use for logging or it will guess the id from the stack trace
|
|
14296
14298
|
* @param dontLogReRender if true, will not log the re-render message nice if you have a lot of re-renders
|
|
14297
14299
|
* @example
|
|
14298
14300
|
* const propsToWatch = { foo: props.foo, bar: props.bar };
|
|
@@ -14364,10 +14366,12 @@ const useDebugger = (propsToWatch, id, dontLogReRender) => {
|
|
|
14364
14366
|
* This component will log when it is mounted, re-renders or unmounted.
|
|
14365
14367
|
* It will also log when any of its props change.
|
|
14366
14368
|
*
|
|
14367
|
-
* @param
|
|
14368
|
-
* @param
|
|
14369
|
-
* @param
|
|
14370
|
-
* @param
|
|
14369
|
+
* @param props - The component props.
|
|
14370
|
+
* @param props.id - Optional id to use for logging.
|
|
14371
|
+
* @param props.stop - If true, will stop execution and open debugger.
|
|
14372
|
+
* @param props.logPropsChanges - Optional object with props to watch for changes.
|
|
14373
|
+
* @param props.children - The children to render.
|
|
14374
|
+
* @returns {ReactElement} The rendered debugger component.
|
|
14371
14375
|
*/
|
|
14372
14376
|
const Debugger = ({ id, logPropsChanges, stop, children, }) => {
|
|
14373
14377
|
const uniqueId = id ||
|
|
@@ -14464,16 +14468,18 @@ const queryFor = (document, variables, data, error, maxUsageCount = 1) => {
|
|
|
14464
14468
|
};
|
|
14465
14469
|
};
|
|
14466
14470
|
/**
|
|
14471
|
+
* Creates a mocked response for a hook query.
|
|
14467
14472
|
*
|
|
14468
|
-
* @param
|
|
14469
|
-
* @param
|
|
14473
|
+
* @param hookFn - The hook function that executes the query.
|
|
14474
|
+
* @param document - Document that represents the specific GQL query / mutation schema.
|
|
14475
|
+
* @param variables - Variables that should be passed to the query / mutation.
|
|
14470
14476
|
* Note that an *exact* match between the mock and operation is necessary.
|
|
14471
|
-
* @param data Data object to be returned.
|
|
14477
|
+
* @param data - Data object to be returned.
|
|
14472
14478
|
* Note that *all* properties should be given a value, use `null` in place of `undefined`,
|
|
14473
14479
|
* otherwise nothing will be returned.
|
|
14474
|
-
* @param error ApolloError object to be returned.
|
|
14475
|
-
* @returns {MockedResponse} that can be passed to the mocked ApolloProvider.
|
|
14476
|
-
* @see
|
|
14480
|
+
* @param error - ApolloError object to be returned.
|
|
14481
|
+
* @returns {MockedResponse} MockedResponse that can be passed to the mocked ApolloProvider.
|
|
14482
|
+
* @see Testing React components using MockedProvider and associated APIs (https://www.apollographql.com/docs/react/development-testing/testing/)
|
|
14477
14483
|
*/
|
|
14478
14484
|
const queryForHook = (hookFn, document, variables, data, error) => {
|
|
14479
14485
|
return {
|
package/index.esm2.js
CHANGED
|
@@ -13526,9 +13526,10 @@ const RootRouteDebugger = () => {
|
|
|
13526
13526
|
/**
|
|
13527
13527
|
* This component is used to wrap the children of the RouterContainer to add a test root container.
|
|
13528
13528
|
*
|
|
13529
|
-
* @param
|
|
13530
|
-
* @param
|
|
13531
|
-
* @
|
|
13529
|
+
* @param props - The component props.
|
|
13530
|
+
* @param props.addTestRootContainer - Boolean to add test root container.
|
|
13531
|
+
* @param props.children - Children to be wrapped.
|
|
13532
|
+
* @returns {ReactNode} Children component wrapped in a test root container.
|
|
13532
13533
|
*/
|
|
13533
13534
|
const TestRenderChildren = ({ addTestRootContainer, children }) => {
|
|
13534
13535
|
return addTestRootContainer ? (jsx("div", { className: "inline-block h-[1000px] w-[1024px] scale-[.99]", "data-testid": "testRoot", style: {
|
|
@@ -13539,11 +13540,12 @@ const TestRenderChildren = ({ addTestRootContainer, children }) => {
|
|
|
13539
13540
|
/**
|
|
13540
13541
|
* This component is used to wrap the children of the RouterContainer to add a test root container.
|
|
13541
13542
|
*
|
|
13542
|
-
* @param
|
|
13543
|
-
* @param
|
|
13544
|
-
* @param
|
|
13545
|
-
* @param
|
|
13546
|
-
* @
|
|
13543
|
+
* @param props - The component props.
|
|
13544
|
+
* @param props.addTestRootContainer - Boolean to add test root container.
|
|
13545
|
+
* @param props.selectedRouterProps - Selected router props.
|
|
13546
|
+
* @param props.rootRoute - Root route.
|
|
13547
|
+
* @param props.children - Children to be wrapped.
|
|
13548
|
+
* @returns {ReactElement} Children component wrapped in a test root container.
|
|
13547
13549
|
*/
|
|
13548
13550
|
const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute, children, }) => {
|
|
13549
13551
|
const client = useApolloClient();
|
|
@@ -14269,8 +14271,8 @@ const useIsFirstRender = () => {
|
|
|
14269
14271
|
* This is a hook version of the class component lifecycle method `componentDidUpdate`.
|
|
14270
14272
|
* ALWAYS wrap in your own object.
|
|
14271
14273
|
*
|
|
14272
|
-
* @param id optional id to use for logging or it will guess the id from the stack trace
|
|
14273
14274
|
* @param propsToWatch all the props to watch for changes
|
|
14275
|
+
* @param id optional id to use for logging or it will guess the id from the stack trace
|
|
14274
14276
|
* @param dontLogReRender if true, will not log the re-render message nice if you have a lot of re-renders
|
|
14275
14277
|
* @example
|
|
14276
14278
|
* const propsToWatch = { foo: props.foo, bar: props.bar };
|
|
@@ -14342,10 +14344,12 @@ const useDebugger = (propsToWatch, id, dontLogReRender) => {
|
|
|
14342
14344
|
* This component will log when it is mounted, re-renders or unmounted.
|
|
14343
14345
|
* It will also log when any of its props change.
|
|
14344
14346
|
*
|
|
14345
|
-
* @param
|
|
14346
|
-
* @param
|
|
14347
|
-
* @param
|
|
14348
|
-
* @param
|
|
14347
|
+
* @param props - The component props.
|
|
14348
|
+
* @param props.id - Optional id to use for logging.
|
|
14349
|
+
* @param props.stop - If true, will stop execution and open debugger.
|
|
14350
|
+
* @param props.logPropsChanges - Optional object with props to watch for changes.
|
|
14351
|
+
* @param props.children - The children to render.
|
|
14352
|
+
* @returns {ReactElement} The rendered debugger component.
|
|
14349
14353
|
*/
|
|
14350
14354
|
const Debugger = ({ id, logPropsChanges, stop, children, }) => {
|
|
14351
14355
|
const uniqueId = id ||
|
|
@@ -14442,16 +14446,18 @@ const queryFor = (document, variables, data, error, maxUsageCount = 1) => {
|
|
|
14442
14446
|
};
|
|
14443
14447
|
};
|
|
14444
14448
|
/**
|
|
14449
|
+
* Creates a mocked response for a hook query.
|
|
14445
14450
|
*
|
|
14446
|
-
* @param
|
|
14447
|
-
* @param
|
|
14451
|
+
* @param hookFn - The hook function that executes the query.
|
|
14452
|
+
* @param document - Document that represents the specific GQL query / mutation schema.
|
|
14453
|
+
* @param variables - Variables that should be passed to the query / mutation.
|
|
14448
14454
|
* Note that an *exact* match between the mock and operation is necessary.
|
|
14449
|
-
* @param data Data object to be returned.
|
|
14455
|
+
* @param data - Data object to be returned.
|
|
14450
14456
|
* Note that *all* properties should be given a value, use `null` in place of `undefined`,
|
|
14451
14457
|
* otherwise nothing will be returned.
|
|
14452
|
-
* @param error ApolloError object to be returned.
|
|
14453
|
-
* @returns {MockedResponse} that can be passed to the mocked ApolloProvider.
|
|
14454
|
-
* @see
|
|
14458
|
+
* @param error - ApolloError object to be returned.
|
|
14459
|
+
* @returns {MockedResponse} MockedResponse that can be passed to the mocked ApolloProvider.
|
|
14460
|
+
* @see Testing React components using MockedProvider and associated APIs (https://www.apollographql.com/docs/react/development-testing/testing/)
|
|
14455
14461
|
*/
|
|
14456
14462
|
const queryForHook = (hookFn, document, variables, data, error) => {
|
|
14457
14463
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-core-contexts-test",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
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.13.
|
|
13
|
+
"@trackunit/shared-utils": "1.13.20",
|
|
14
14
|
"graphql": "^16.10.0",
|
|
15
15
|
"@tanstack/router-core": "1.114.29",
|
|
16
|
-
"@trackunit/iris-app-runtime-core-api": "1.
|
|
17
|
-
"@trackunit/react-core-contexts-api": "1.
|
|
16
|
+
"@trackunit/iris-app-runtime-core-api": "1.12.1",
|
|
17
|
+
"@trackunit/react-core-contexts-api": "1.13.1",
|
|
18
18
|
"es-toolkit": "^1.39.10"
|
|
19
19
|
},
|
|
20
20
|
"module": "./index.esm.js",
|
package/src/useDebugger.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
2
|
type PropsToWatch<TProps> = TProps extends object ? TProps : never;
|
|
3
3
|
/**
|
|
4
4
|
* Logs props that have changed.
|
|
@@ -6,8 +6,8 @@ type PropsToWatch<TProps> = TProps extends object ? TProps : never;
|
|
|
6
6
|
* This is a hook version of the class component lifecycle method `componentDidUpdate`.
|
|
7
7
|
* ALWAYS wrap in your own object.
|
|
8
8
|
*
|
|
9
|
-
* @param id optional id to use for logging or it will guess the id from the stack trace
|
|
10
9
|
* @param propsToWatch all the props to watch for changes
|
|
10
|
+
* @param id optional id to use for logging or it will guess the id from the stack trace
|
|
11
11
|
* @param dontLogReRender if true, will not log the re-render message nice if you have a lot of re-renders
|
|
12
12
|
* @example
|
|
13
13
|
* const propsToWatch = { foo: props.foo, bar: props.bar };
|
|
@@ -20,15 +20,17 @@ export declare const useDebugger: <TProps extends object>(propsToWatch: PropsToW
|
|
|
20
20
|
* This component will log when it is mounted, re-renders or unmounted.
|
|
21
21
|
* It will also log when any of its props change.
|
|
22
22
|
*
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
23
|
+
* @param props - The component props.
|
|
24
|
+
* @param props.id - Optional id to use for logging.
|
|
25
|
+
* @param props.stop - If true, will stop execution and open debugger.
|
|
26
|
+
* @param props.logPropsChanges - Optional object with props to watch for changes.
|
|
27
|
+
* @param props.children - The children to render.
|
|
28
|
+
* @returns {ReactElement} The rendered debugger component.
|
|
27
29
|
*/
|
|
28
30
|
export declare const Debugger: ({ id, logPropsChanges, stop, children, }: {
|
|
29
31
|
children?: ReactNode;
|
|
30
32
|
id?: string;
|
|
31
33
|
stop?: boolean;
|
|
32
34
|
logPropsChanges?: Record<string, unknown>;
|
|
33
|
-
}) =>
|
|
35
|
+
}) => ReactElement;
|
|
34
36
|
export {};
|
package/src/utils/queryFor.d.ts
CHANGED
|
@@ -36,16 +36,18 @@ export declare const queryFor: <TData, TVariables extends OperationVariables = O
|
|
|
36
36
|
type QueryReturn<TData, TVariables extends OperationVariables = OperationVariables> = ReturnType<typeof useQuery<TData, TVariables>>;
|
|
37
37
|
type QueryLazyReturn<TData, TVariables extends OperationVariables = OperationVariables> = ReturnType<typeof useLazyQuery<TData, TVariables>>;
|
|
38
38
|
/**
|
|
39
|
+
* Creates a mocked response for a hook query.
|
|
39
40
|
*
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
41
|
+
* @param hookFn - The hook function that executes the query.
|
|
42
|
+
* @param document - Document that represents the specific GQL query / mutation schema.
|
|
43
|
+
* @param variables - Variables that should be passed to the query / mutation.
|
|
42
44
|
* Note that an *exact* match between the mock and operation is necessary.
|
|
43
|
-
* @param data Data object to be returned.
|
|
45
|
+
* @param data - Data object to be returned.
|
|
44
46
|
* Note that *all* properties should be given a value, use `null` in place of `undefined`,
|
|
45
47
|
* otherwise nothing will be returned.
|
|
46
|
-
* @param error ApolloError object to be returned.
|
|
47
|
-
* @returns {MockedResponse} that can be passed to the mocked ApolloProvider.
|
|
48
|
-
* @see
|
|
48
|
+
* @param error - ApolloError object to be returned.
|
|
49
|
+
* @returns {MockedResponse} MockedResponse that can be passed to the mocked ApolloProvider.
|
|
50
|
+
* @see Testing React components using MockedProvider and associated APIs (https://www.apollographql.com/docs/react/development-testing/testing/)
|
|
49
51
|
*/
|
|
50
52
|
export declare const queryForHook: <TData, TVariables extends OperationVariables = OperationVariables>(hookFn: (baseOptions: QueryHookOptions<TData, TVariables>) => QueryReturn<TData, TVariables> | QueryLazyReturn<TData, TVariables>, document: TypedDocumentNode<TData, TVariables>, variables: TVariables, data: TData | null, error?: ApolloError | Error) => MockedResponse;
|
|
51
53
|
export {};
|
|
@@ -24,11 +24,12 @@ export interface TestRenderChildrenProps {
|
|
|
24
24
|
/**
|
|
25
25
|
* This component is used to wrap the children of the RouterContainer to add a test root container.
|
|
26
26
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @
|
|
27
|
+
* @param props - The component props.
|
|
28
|
+
* @param props.addTestRootContainer - Boolean to add test root container.
|
|
29
|
+
* @param props.children - Children to be wrapped.
|
|
30
|
+
* @returns {ReactNode} Children component wrapped in a test root container.
|
|
30
31
|
*/
|
|
31
|
-
export declare const TestRenderChildren: ({ addTestRootContainer, children }: TestRenderChildrenProps) =>
|
|
32
|
+
export declare const TestRenderChildren: ({ addTestRootContainer, children }: TestRenderChildrenProps) => ReactNode;
|
|
32
33
|
export interface RouterContainerProps<TRoute extends AnyRoute = AnyRoute> {
|
|
33
34
|
addTestRootContainer: boolean;
|
|
34
35
|
rootRoute?: TRoute | null;
|
|
@@ -38,10 +39,11 @@ export interface RouterContainerProps<TRoute extends AnyRoute = AnyRoute> {
|
|
|
38
39
|
/**
|
|
39
40
|
* This component is used to wrap the children of the RouterContainer to add a test root container.
|
|
40
41
|
*
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @
|
|
42
|
+
* @param props - The component props.
|
|
43
|
+
* @param props.addTestRootContainer - Boolean to add test root container.
|
|
44
|
+
* @param props.selectedRouterProps - Selected router props.
|
|
45
|
+
* @param props.rootRoute - Root route.
|
|
46
|
+
* @param props.children - Children to be wrapped.
|
|
47
|
+
* @returns {ReactElement} Children component wrapped in a test root container.
|
|
46
48
|
*/
|
|
47
49
|
export declare const RouterContainer: ({ addTestRootContainer, selectedRouterProps, rootRoute, children, }: RouterContainerProps) => ReactElement;
|