@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.
Files changed (42) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/build/esnext/_virtual/index7.esnext +2 -2
  3. package/build/esnext/_virtual/index8.esnext +2 -2
  4. package/build/esnext/node_modules/.pnpm/dir-glob@3.0.1/node_modules/dir-glob/index.esnext +1 -1
  5. package/build/esnext/node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/readers/stream.esnext +1 -1
  6. package/build/esnext/node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/utils/index.esnext +1 -1
  7. package/build/esnext/node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/utils/stream.esnext +1 -1
  8. package/package.json +1 -1
  9. package/templates/app-basic/App.tsx +8 -13
  10. package/templates/app-basic/browser.tsx +20 -39
  11. package/templates/app-basic/context/browser.ts +7 -3
  12. package/templates/app-basic/context/navigation.ts +6 -13
  13. package/templates/app-basic/context/preact.ts +9 -0
  14. package/templates/app-basic/context/server.ts +10 -3
  15. package/templates/app-basic/context/types.ts +20 -1
  16. package/templates/app-basic/package.json +1 -1
  17. package/templates/app-basic/tests/render/render.tsx +17 -22
  18. package/templates/app-basic/tests/render/types.ts +17 -13
  19. package/templates/app-basic/tests/render.ts +1 -1
  20. package/templates/app-empty/package.json +1 -1
  21. package/templates/app-graphql/App.tsx +10 -16
  22. package/templates/app-graphql/browser.tsx +20 -39
  23. package/templates/app-graphql/context/browser.ts +9 -13
  24. package/templates/app-graphql/context/navigation.ts +6 -13
  25. package/templates/app-graphql/context/preact.ts +9 -0
  26. package/templates/app-graphql/context/server.ts +13 -12
  27. package/templates/app-graphql/context/types.ts +23 -6
  28. package/templates/app-graphql/package.json +1 -1
  29. package/templates/app-graphql/tests/render/render.tsx +17 -37
  30. package/templates/app-graphql/tests/render/types.ts +20 -45
  31. package/templates/app-graphql/tests/render.ts +1 -1
  32. package/templates/app-trpc/App.tsx +15 -17
  33. package/templates/app-trpc/browser.tsx +20 -39
  34. package/templates/app-trpc/context/browser.ts +8 -4
  35. package/templates/app-trpc/context/navigation.ts +6 -13
  36. package/templates/app-trpc/context/preact.ts +9 -0
  37. package/templates/app-trpc/context/server.ts +11 -4
  38. package/templates/app-trpc/context/types.ts +27 -3
  39. package/templates/app-trpc/package.json +1 -1
  40. package/templates/app-trpc/tests/render/render.tsx +25 -29
  41. package/templates/app-trpc/tests/render/types.ts +17 -16
  42. package/templates/app-trpc/tests/render.ts +1 -1
@@ -1,15 +1,12 @@
1
1
  import {createRender} from '@quilted/quilt/testing';
2
- import {
3
- BrowserDetailsContext,
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({router = new TestRouter(), browser = new BrowserTestMock()}) {
26
+ context({
27
+ navigation = new TestNavigation(),
28
+ browser = new TestBrowser(),
29
+ localization = new Localization('en'),
30
+ }) {
30
31
  return {
31
- navigation: {router},
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(element, context, {locale = 'en'}) {
39
- const {
40
- navigation: {router},
41
- browser,
42
- trpc: trpcClient,
43
- queryClient,
44
- } = context;
45
-
40
+ render(
41
+ element,
42
+ {navigation, browser, localization, trpc: trpcClient, queryClient},
43
+ ) {
46
44
  return (
47
- <AppContextPreact.Provider value={context}>
48
- <BrowserDetailsContext.Provider value={browser}>
49
- <Localization locale={locale}>
50
- <Navigation router={router}>
51
- <trpc.Provider client={trpcClient} queryClient={queryClient}>
52
- <QueryClientProvider client={queryClient}>
53
- {element}
54
- </QueryClientProvider>
55
- </trpc.Provider>
56
- </Navigation>
57
- </Localization>
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 {TestRouter} from '@quilted/quilt/navigation/testing';
2
- import type {BrowserTestMock} from '@quilted/quilt/browser/testing';
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 router to use for this component test. You can use a
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 router?: TestRouter;
10
+ readonly navigation?: TestNavigation;
15
11
 
16
12
  /**
17
13
  * A custom environment for this component test.
18
14
  */
19
- readonly browser?: BrowserTestMock;
15
+ readonly browser?: TestBrowser;
20
16
 
21
17
  /**
22
- * A custom locale to use for this component test.
18
+ * A custom localization instance to use for this component test.
23
19
  */
24
- readonly locale?: string;
20
+ readonly localization?: Localization;
25
21
  }
26
22
 
27
- export interface RenderContext extends AppContext {
23
+ export interface RenderContext {
28
24
  /**
29
- * The router used for this component test.
25
+ * The navigation used for this component test.
30
26
  */
31
- readonly navigation: {router: TestRouter};
27
+ readonly navigation: TestNavigation;
32
28
 
33
29
  /**
34
30
  * The browser environment for this component test.
35
31
  */
36
- readonly browser: BrowserTestMock;
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.
@@ -1,6 +1,6 @@
1
1
  import '@quilted/quilt/testing';
2
2
 
3
- export {TestRouter} from '@quilted/quilt/navigation/testing';
3
+ export {TestNavigation} from '@quilted/quilt/navigation/testing';
4
4
 
5
5
  export * from './render/types.ts';
6
6
  export {renderApp} from './render/render.tsx';