@quilted/create 0.3.2 → 0.3.4
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 +111 -0
- package/build/esnext/_virtual/index7.esnext +2 -2
- package/build/esnext/_virtual/index8.esnext +2 -2
- package/build/esnext/node_modules/.pnpm/dir-glob@3.0.1/node_modules/dir-glob/index.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/readers/stream.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/utils/index.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/utils/stream.esnext +1 -1
- package/package.json +1 -1
- package/templates/app-basic/App.tsx +8 -13
- package/templates/app-basic/browser.tsx +20 -39
- package/templates/app-basic/context/browser.ts +7 -3
- package/templates/app-basic/context/navigation.ts +6 -13
- package/templates/app-basic/context/preact.ts +9 -0
- package/templates/app-basic/context/server.ts +10 -3
- package/templates/app-basic/context/types.ts +20 -1
- package/templates/app-basic/package.json +1 -1
- package/templates/app-basic/tests/render/render.tsx +17 -22
- package/templates/app-basic/tests/render/types.ts +17 -13
- package/templates/app-basic/tests/render.ts +1 -1
- package/templates/app-empty/package.json +1 -1
- package/templates/app-graphql/App.tsx +10 -16
- package/templates/app-graphql/browser.tsx +20 -39
- package/templates/app-graphql/context/browser.ts +9 -13
- package/templates/app-graphql/context/navigation.ts +6 -13
- package/templates/app-graphql/context/preact.ts +9 -0
- package/templates/app-graphql/context/server.ts +13 -12
- package/templates/app-graphql/context/types.ts +23 -6
- package/templates/app-graphql/package.json +1 -1
- package/templates/app-graphql/tests/render/render.tsx +17 -37
- package/templates/app-graphql/tests/render/types.ts +20 -45
- package/templates/app-graphql/tests/render.ts +1 -1
- package/templates/app-trpc/App.tsx +15 -17
- package/templates/app-trpc/browser.tsx +20 -39
- package/templates/app-trpc/context/browser.ts +8 -4
- package/templates/app-trpc/context/navigation.ts +6 -13
- package/templates/app-trpc/context/preact.ts +9 -0
- package/templates/app-trpc/context/server.ts +11 -4
- package/templates/app-trpc/context/types.ts +27 -3
- package/templates/app-trpc/package.json +1 -1
- package/templates/app-trpc/tests/render/render.tsx +25 -29
- package/templates/app-trpc/tests/render/types.ts +17 -16
- package/templates/app-trpc/tests/render.ts +1 -1
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import {createRender} from '@quilted/quilt/testing';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
BrowserTestMock,
|
|
5
|
-
} from '@quilted/quilt/browser/testing';
|
|
6
|
-
import {Navigation, TestRouter} from '@quilted/quilt/navigation/testing';
|
|
2
|
+
import {TestBrowser} from '@quilted/quilt/browser/testing';
|
|
3
|
+
import {TestNavigation} from '@quilted/quilt/navigation/testing';
|
|
7
4
|
import {Localization} from '@quilted/quilt/localize';
|
|
5
|
+
import {QuiltFrameworkTestContext} from '@quilted/quilt/context/testing';
|
|
8
6
|
|
|
9
7
|
import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
|
|
10
8
|
|
|
11
9
|
import {trpc} from '~/context/trpc.ts';
|
|
12
|
-
import {AppContextPreact} from '~/context/preact.ts';
|
|
13
10
|
|
|
14
11
|
import {RenderOptions, RenderContext, RenderActions} from './types.ts';
|
|
15
12
|
|
|
@@ -26,37 +23,36 @@ export const renderApp = createRender<
|
|
|
26
23
|
// Create context that can be used by the `render` function, and referenced by test
|
|
27
24
|
// authors on the `root.context` property. Context is used to share data between your
|
|
28
25
|
// React tree and your test code, and is ideal for mocking out global context providers.
|
|
29
|
-
context({
|
|
26
|
+
context({
|
|
27
|
+
navigation = new TestNavigation(),
|
|
28
|
+
browser = new TestBrowser(),
|
|
29
|
+
localization = new Localization('en'),
|
|
30
|
+
}) {
|
|
30
31
|
return {
|
|
31
|
-
navigation
|
|
32
|
+
navigation,
|
|
32
33
|
browser,
|
|
34
|
+
localization,
|
|
33
35
|
trpc: trpc.createClient(),
|
|
34
36
|
queryClient: new QueryClient(),
|
|
35
37
|
};
|
|
36
38
|
},
|
|
37
39
|
// Render all of our app-wide context providers around each component under test.
|
|
38
|
-
render(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
trpc: trpcClient,
|
|
43
|
-
queryClient,
|
|
44
|
-
} = context;
|
|
45
|
-
|
|
40
|
+
render(
|
|
41
|
+
element,
|
|
42
|
+
{navigation, browser, localization, trpc: trpcClient, queryClient},
|
|
43
|
+
) {
|
|
46
44
|
return (
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
</BrowserDetailsContext.Provider>
|
|
59
|
-
</AppContextPreact.Provider>
|
|
45
|
+
<QuiltFrameworkTestContext
|
|
46
|
+
navigation={navigation}
|
|
47
|
+
browser={browser}
|
|
48
|
+
localization={localization}
|
|
49
|
+
>
|
|
50
|
+
<trpc.Provider client={trpcClient} queryClient={queryClient}>
|
|
51
|
+
<QueryClientProvider client={queryClient}>
|
|
52
|
+
{element}
|
|
53
|
+
</QueryClientProvider>
|
|
54
|
+
</trpc.Provider>
|
|
55
|
+
</QuiltFrameworkTestContext>
|
|
60
56
|
);
|
|
61
57
|
},
|
|
62
58
|
async afterRender() {
|
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type {TestNavigation} from '@quilted/quilt/navigation/testing';
|
|
2
|
+
import type {TestBrowser} from '@quilted/quilt/browser/testing';
|
|
3
|
+
import type {Localization} from '@quilted/quilt/localize';
|
|
3
4
|
import type {QueryClient} from '@tanstack/react-query';
|
|
4
5
|
|
|
5
|
-
import type {AppContext} from '~/context/types.ts';
|
|
6
|
-
|
|
7
6
|
export interface RenderOptions {
|
|
8
7
|
/**
|
|
9
|
-
* A custom
|
|
10
|
-
* custom router to simulate a particular URL, and you can spy on
|
|
11
|
-
* its navigation method to check that components navigate as
|
|
12
|
-
* you expect.
|
|
8
|
+
* A custom navigation to use for this component test.
|
|
13
9
|
*/
|
|
14
|
-
readonly
|
|
10
|
+
readonly navigation?: TestNavigation;
|
|
15
11
|
|
|
16
12
|
/**
|
|
17
13
|
* A custom environment for this component test.
|
|
18
14
|
*/
|
|
19
|
-
readonly browser?:
|
|
15
|
+
readonly browser?: TestBrowser;
|
|
20
16
|
|
|
21
17
|
/**
|
|
22
|
-
* A custom
|
|
18
|
+
* A custom localization instance to use for this component test.
|
|
23
19
|
*/
|
|
24
|
-
readonly
|
|
20
|
+
readonly localization?: Localization;
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
export interface RenderContext
|
|
23
|
+
export interface RenderContext {
|
|
28
24
|
/**
|
|
29
|
-
* The
|
|
25
|
+
* The navigation used for this component test.
|
|
30
26
|
*/
|
|
31
|
-
readonly navigation:
|
|
27
|
+
readonly navigation: TestNavigation;
|
|
32
28
|
|
|
33
29
|
/**
|
|
34
30
|
* The browser environment for this component test.
|
|
35
31
|
*/
|
|
36
|
-
readonly browser:
|
|
32
|
+
readonly browser: TestBrowser;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The localization used for this component test.
|
|
36
|
+
*/
|
|
37
|
+
readonly localization: Localization;
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* The react-query client used for this component test.
|