@quilted/create 0.1.58 → 0.1.59
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/templates/app-basic/shared/context.ts +14 -0
- package/templates/app-basic/tests/render.tsx +12 -9
- package/templates/app-graphql/shared/context.ts +14 -0
- package/templates/app-graphql/tests/render.tsx +18 -8
- package/templates/app-basic/shared/types.ts +0 -1
- package/templates/app-graphql/shared/types.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @quilted/create
|
|
2
2
|
|
|
3
|
+
## 0.1.59
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ab07f855`](https://github.com/lemonmade/quilt/commit/ab07f855c65011cd437d198ba7b7eec590b6c8c3) Thanks [@lemonmade](https://github.com/lemonmade)! - Improve app templates
|
|
8
|
+
|
|
3
9
|
## 0.1.58
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createOptionalContext,
|
|
3
|
+
createUseContextHook,
|
|
4
|
+
createUseOptionalValueHook,
|
|
5
|
+
} from '@quilted/quilt';
|
|
6
|
+
|
|
7
|
+
export interface AppContext {}
|
|
8
|
+
|
|
9
|
+
export const AppContextReact = createOptionalContext<AppContext>();
|
|
10
|
+
export const useAppContext = createUseContextHook(AppContextReact);
|
|
11
|
+
|
|
12
|
+
export function createUseAppContextHook<T>(hook: (context: AppContext) => T) {
|
|
13
|
+
return createUseOptionalValueHook<T>(() => hook(useAppContext()));
|
|
14
|
+
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import '@quilted/quilt/matchers';
|
|
2
2
|
|
|
3
|
-
import {type PropsWithChildren} from '@quilted/quilt';
|
|
4
3
|
import {
|
|
5
4
|
createRender,
|
|
6
5
|
QuiltAppTesting,
|
|
7
6
|
createTestRouter,
|
|
8
7
|
} from '@quilted/quilt/testing';
|
|
9
8
|
|
|
9
|
+
import {
|
|
10
|
+
AppContextReact,
|
|
11
|
+
type AppContext as AppContextType,
|
|
12
|
+
} from '~/shared/context.ts';
|
|
13
|
+
|
|
10
14
|
type Router = ReturnType<typeof createTestRouter>;
|
|
11
15
|
|
|
12
16
|
export {createTestRouter};
|
|
@@ -26,7 +30,7 @@ export interface RenderOptions {
|
|
|
26
30
|
locale?: string;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
export interface RenderContext {
|
|
33
|
+
export interface RenderContext extends AppContextType {
|
|
30
34
|
/**
|
|
31
35
|
* The router used for this component test.
|
|
32
36
|
*/
|
|
@@ -52,10 +56,14 @@ export const renderWithAppContext = createRender<
|
|
|
52
56
|
return {router};
|
|
53
57
|
},
|
|
54
58
|
// Render all of our app-wide context providers around each component under test.
|
|
55
|
-
render(element,
|
|
59
|
+
render(element, context, {locale}) {
|
|
60
|
+
const {router} = context;
|
|
61
|
+
|
|
56
62
|
return (
|
|
57
63
|
<QuiltAppTesting routing={router} localization={locale}>
|
|
58
|
-
<
|
|
64
|
+
<AppContextReact.Provider value={context}>
|
|
65
|
+
{element}
|
|
66
|
+
</AppContextReact.Provider>
|
|
59
67
|
</QuiltAppTesting>
|
|
60
68
|
);
|
|
61
69
|
},
|
|
@@ -66,8 +74,3 @@ export const renderWithAppContext = createRender<
|
|
|
66
74
|
// once the data is ready.
|
|
67
75
|
},
|
|
68
76
|
});
|
|
69
|
-
|
|
70
|
-
// This component renders any app-wide context needed for component tests.
|
|
71
|
-
function TestAppContext({children}: PropsWithChildren) {
|
|
72
|
-
return <>{children}</>;
|
|
73
|
-
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createOptionalContext,
|
|
3
|
+
createUseContextHook,
|
|
4
|
+
createUseOptionalValueHook,
|
|
5
|
+
} from '@quilted/quilt';
|
|
6
|
+
|
|
7
|
+
export interface AppContext {}
|
|
8
|
+
|
|
9
|
+
export const AppContextReact = createOptionalContext<AppContext>();
|
|
10
|
+
export const useAppContext = createUseContextHook(AppContextReact);
|
|
11
|
+
|
|
12
|
+
export function createUseAppContextHook<T>(hook: (context: AppContext) => T) {
|
|
13
|
+
return createUseOptionalValueHook<T>(() => hook(useAppContext()));
|
|
14
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import '@quilted/quilt/matchers';
|
|
2
2
|
|
|
3
|
-
import {type Router} from '@quilted/quilt';
|
|
4
3
|
import {
|
|
5
4
|
createRender,
|
|
6
5
|
QuiltAppTesting,
|
|
@@ -8,6 +7,11 @@ import {
|
|
|
8
7
|
} from '@quilted/quilt/testing';
|
|
9
8
|
import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
|
|
10
9
|
|
|
10
|
+
import {
|
|
11
|
+
AppContextReact,
|
|
12
|
+
type AppContext as AppContextType,
|
|
13
|
+
} from '~/shared/context.ts';
|
|
14
|
+
|
|
11
15
|
import {
|
|
12
16
|
TestGraphQL,
|
|
13
17
|
fillGraphQL,
|
|
@@ -15,6 +19,8 @@ import {
|
|
|
15
19
|
type GraphQLController,
|
|
16
20
|
} from './graphql.ts';
|
|
17
21
|
|
|
22
|
+
type Router = ReturnType<typeof createTestRouter>;
|
|
23
|
+
|
|
18
24
|
export {createTestRouter, fillGraphQL, createGraphQLController};
|
|
19
25
|
|
|
20
26
|
export interface RenderOptions {
|
|
@@ -53,7 +59,7 @@ export interface RenderOptions {
|
|
|
53
59
|
locale?: string;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
export interface RenderContext {
|
|
62
|
+
export interface RenderContext extends AppContextType {
|
|
57
63
|
/**
|
|
58
64
|
* The router used for this component test.
|
|
59
65
|
*/
|
|
@@ -89,14 +95,18 @@ export const renderWithAppContext = createRender<
|
|
|
89
95
|
return {router, graphql, queryClient: new QueryClient()};
|
|
90
96
|
},
|
|
91
97
|
// Render all of our app-wide context providers around each component under test.
|
|
92
|
-
render(element,
|
|
98
|
+
render(element, context, {locale}) {
|
|
99
|
+
const {router, graphql, queryClient} = context;
|
|
100
|
+
|
|
93
101
|
return (
|
|
94
102
|
<QuiltAppTesting routing={router} localization={locale}>
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
{
|
|
98
|
-
|
|
99
|
-
|
|
103
|
+
<AppContextReact.Provider value={context}>
|
|
104
|
+
<TestGraphQL controller={graphql}>
|
|
105
|
+
<QueryClientProvider client={queryClient}>
|
|
106
|
+
{element}
|
|
107
|
+
</QueryClientProvider>
|
|
108
|
+
</TestGraphQL>
|
|
109
|
+
</AppContextReact.Provider>
|
|
100
110
|
</QuiltAppTesting>
|
|
101
111
|
);
|
|
102
112
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|