@thepalaceproject/circulation-admin 1.29.0-post.2 → 1.29.0-post.3
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/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
useAppEmail,
|
|
6
6
|
useAppFeatureFlags,
|
|
7
7
|
useCsrfToken,
|
|
8
|
+
useTermsOfService,
|
|
8
9
|
} from "../../../src/context/appContext";
|
|
9
10
|
import { componentWithProviders } from "../testUtils/withProviders";
|
|
10
11
|
import { ContextProviderProps } from "../../../src/components/ContextProvider";
|
|
@@ -25,12 +26,18 @@ describe("AppContext", () => {
|
|
|
25
26
|
testFalse: false,
|
|
26
27
|
};
|
|
27
28
|
const expectedRoles = [{ role: "system" }];
|
|
29
|
+
const expectedTermsOfService = {
|
|
30
|
+
text: "Terms of Service",
|
|
31
|
+
href: "/terms-of-service",
|
|
32
|
+
};
|
|
28
33
|
|
|
29
34
|
const contextProviderProps: ContextProviderProps = {
|
|
30
35
|
csrfToken: expectedCsrfToken,
|
|
31
36
|
featureFlags: expectedFeatureFlags,
|
|
32
37
|
roles: expectedRoles,
|
|
33
38
|
email: expectedEmail,
|
|
39
|
+
tos_link_text: expectedTermsOfService.text,
|
|
40
|
+
tos_link_href: expectedTermsOfService.href,
|
|
34
41
|
};
|
|
35
42
|
const wrapper = componentWithProviders({ contextProviderProps });
|
|
36
43
|
|
|
@@ -69,4 +76,15 @@ describe("AppContext", () => {
|
|
|
69
76
|
const flags = result.current;
|
|
70
77
|
expect(flags).toEqual(expectedFeatureFlags);
|
|
71
78
|
});
|
|
79
|
+
|
|
80
|
+
it("provides useTermsOfService context hook", () => {
|
|
81
|
+
const { result } = renderHook(() => useTermsOfService(), {
|
|
82
|
+
wrapper,
|
|
83
|
+
});
|
|
84
|
+
const tosLink = result.current;
|
|
85
|
+
const { text, href } = tosLink;
|
|
86
|
+
expect(tosLink).toEqual(expectedTermsOfService);
|
|
87
|
+
expect(text).toEqual(expectedTermsOfService.text);
|
|
88
|
+
expect(href).toEqual(expectedTermsOfService.href);
|
|
89
|
+
});
|
|
72
90
|
});
|
|
@@ -7,15 +7,10 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
|
7
7
|
import { render, RenderOptions, RenderResult } from "@testing-library/react";
|
|
8
8
|
import { defaultFeatureFlags } from "../../../src/utils/featureFlags";
|
|
9
9
|
import { store } from "../../../src/store";
|
|
10
|
-
import {
|
|
11
|
-
TOSContextProvider,
|
|
12
|
-
TOSContextProviderProps,
|
|
13
|
-
} from "../../../src/components/TOSContext";
|
|
14
10
|
|
|
15
11
|
export type TestProviderWrapperOptions = {
|
|
16
12
|
reduxProviderProps?: ProviderProps;
|
|
17
13
|
contextProviderProps?: Partial<ContextProviderProps>;
|
|
18
|
-
tosContextProviderProps?: TOSContextProviderProps;
|
|
19
14
|
queryClient?: QueryClient;
|
|
20
15
|
};
|
|
21
16
|
export type TestRenderWrapperOptions = TestProviderWrapperOptions & {
|
|
@@ -26,13 +21,6 @@ export type TestRenderWrapperOptions = TestProviderWrapperOptions & {
|
|
|
26
21
|
// be the same for both the Redux Provider and the ContextProvider.
|
|
27
22
|
const defaultReduxStore = store;
|
|
28
23
|
|
|
29
|
-
// Setup default TOSContext provider props.
|
|
30
|
-
const tosText = "Sample terms of service.";
|
|
31
|
-
const tosHref = "http://example.com/terms-of-service";
|
|
32
|
-
const requiredTOSContextProviderProps: TOSContextProviderProps = {
|
|
33
|
-
...[tosText, tosHref],
|
|
34
|
-
};
|
|
35
|
-
|
|
36
24
|
// The `csrfToken` context provider prop is required, so we provide
|
|
37
25
|
// a default value here, so it can be easily merged with other props.
|
|
38
26
|
const requiredContextProviderProps: ContextProviderProps = {
|
|
@@ -47,7 +35,6 @@ const requiredContextProviderProps: ContextProviderProps = {
|
|
|
47
35
|
* @param {TestProviderWrapperOptions} options
|
|
48
36
|
* @param options.reduxProviderProps Props to pass to the Redux `Provider` wrapper
|
|
49
37
|
* @param {ContextProviderProps} options.contextProviderProps Props to pass to the ContextProvider wrapper
|
|
50
|
-
* @param {TOSContextProviderProps} options.tosContextProviderProps Props to pass to the TOSContextProvider wrapper
|
|
51
38
|
* @param {QueryClient} options.queryClient A `tanstack/react-query` QueryClient
|
|
52
39
|
* @returns {React.FunctionComponent} A React component that wraps children with our providers
|
|
53
40
|
*/
|
|
@@ -59,7 +46,6 @@ export const componentWithProviders = ({
|
|
|
59
46
|
csrfToken: "",
|
|
60
47
|
featureFlags: defaultFeatureFlags,
|
|
61
48
|
},
|
|
62
|
-
tosContextProviderProps = requiredTOSContextProviderProps,
|
|
63
49
|
queryClient = new QueryClient(),
|
|
64
50
|
}: TestProviderWrapperOptions = {}): React.FunctionComponent => {
|
|
65
51
|
const effectiveContextProviderProps = {
|
|
@@ -70,11 +56,9 @@ export const componentWithProviders = ({
|
|
|
70
56
|
const wrapper = ({ children }) => (
|
|
71
57
|
<Provider {...reduxProviderProps}>
|
|
72
58
|
<ContextProvider {...effectiveContextProviderProps}>
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
</QueryClientProvider>
|
|
77
|
-
</TOSContextProvider>
|
|
59
|
+
<QueryClientProvider client={queryClient}>
|
|
60
|
+
{children}
|
|
61
|
+
</QueryClientProvider>
|
|
78
62
|
</ContextProvider>
|
|
79
63
|
</Provider>
|
|
80
64
|
);
|