@khanacademy/wonder-blocks-testing 7.1.10 → 7.1.11

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 (142) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/es/index.js +183 -120
  3. package/dist/fetch/fetch-request-matches-mock.d.ts +5 -0
  4. package/dist/fetch/fetch-request-matches-mock.js.flow +17 -0
  5. package/dist/fetch/mock-fetch.d.ts +5 -0
  6. package/dist/fetch/mock-fetch.js.flow +13 -0
  7. package/dist/fetch/types.d.ts +9 -0
  8. package/dist/fetch/types.js.flow +19 -0
  9. package/dist/fixtures/fixtures.basic.stories.d.ts +13 -0
  10. package/dist/fixtures/fixtures.basic.stories.js.flow +22 -0
  11. package/dist/fixtures/fixtures.d.ts +19 -0
  12. package/dist/fixtures/fixtures.defaultwrapper.stories.d.ts +9 -0
  13. package/dist/fixtures/fixtures.defaultwrapper.stories.js.flow +17 -0
  14. package/dist/fixtures/fixtures.js.flow +33 -0
  15. package/dist/fixtures/types.d.ts +36 -0
  16. package/dist/fixtures/types.js.flow +37 -0
  17. package/dist/gql/gql-request-matches-mock.d.ts +3 -0
  18. package/dist/gql/gql-request-matches-mock.js.flow +15 -0
  19. package/dist/gql/mock-gql-fetch.d.ts +5 -0
  20. package/dist/gql/mock-gql-fetch.js.flow +13 -0
  21. package/dist/gql/types.d.ts +15 -0
  22. package/dist/gql/types.js.flow +39 -0
  23. package/dist/harness/adapters/adapters.d.ts +35 -0
  24. package/dist/harness/adapters/adapters.js.flow +69 -0
  25. package/dist/harness/adapters/css.d.ts +12 -0
  26. package/dist/harness/adapters/css.js.flow +23 -0
  27. package/dist/harness/adapters/data.d.ts +18 -0
  28. package/dist/harness/adapters/data.js.flow +32 -0
  29. package/dist/harness/adapters/portal.d.ts +12 -0
  30. package/dist/harness/adapters/portal.js.flow +18 -0
  31. package/dist/harness/adapters/router.d.ts +94 -0
  32. package/dist/harness/adapters/router.js.flow +122 -0
  33. package/dist/harness/hook-harness.d.ts +13 -0
  34. package/dist/harness/hook-harness.js.flow +23 -0
  35. package/dist/harness/make-hook-harness.d.ts +17 -0
  36. package/dist/harness/make-hook-harness.js.flow +42 -0
  37. package/dist/harness/make-test-harness.d.ts +18 -0
  38. package/dist/harness/make-test-harness.js.flow +48 -0
  39. package/dist/harness/render-adapters.d.ts +6 -0
  40. package/dist/harness/render-adapters.js.flow +24 -0
  41. package/dist/harness/test-harness.d.ts +32 -0
  42. package/dist/harness/test-harness.js.flow +83 -0
  43. package/dist/harness/types.d.ts +46 -0
  44. package/dist/harness/types.js.flow +66 -0
  45. package/dist/index.d.ts +15 -0
  46. package/dist/index.js +185 -127
  47. package/dist/index.js.flow +26 -2
  48. package/dist/mock-requester.d.ts +5 -0
  49. package/dist/mock-requester.js.flow +22 -0
  50. package/dist/respond-with.d.ts +57 -0
  51. package/dist/respond-with.js.flow +91 -0
  52. package/dist/response-impl.d.ts +1 -0
  53. package/dist/response-impl.js.flow +8 -0
  54. package/dist/settle-controller.d.ts +19 -0
  55. package/dist/settle-controller.js.flow +26 -0
  56. package/dist/settle-signal.d.ts +18 -0
  57. package/dist/settle-signal.js.flow +26 -0
  58. package/dist/types.d.ts +25 -0
  59. package/dist/types.js.flow +46 -0
  60. package/package.json +6 -6
  61. package/src/__tests__/{mock-requester.test.js → mock-requester.test.ts} +1 -2
  62. package/src/__tests__/{respond-with.test.js → respond-with.test.ts} +0 -1
  63. package/src/__tests__/response-impl.test.js +1 -1
  64. package/src/__tests__/{settle-controller.test.js → settle-controller.test.ts} +0 -1
  65. package/src/__tests__/{settle-signal.test.js → settle-signal.test.ts} +0 -1
  66. package/src/fetch/__tests__/__snapshots__/{mock-fetch.test.js.snap → mock-fetch.test.ts.snap} +3 -3
  67. package/src/fetch/__tests__/{fetch-request-matches-mock.test.js → fetch-request-matches-mock.test.ts} +5 -6
  68. package/src/fetch/__tests__/{mock-fetch.test.js → mock-fetch.test.ts} +1 -2
  69. package/src/fetch/{fetch-request-matches-mock.js → fetch-request-matches-mock.ts} +3 -2
  70. package/src/fetch/{mock-fetch.js → mock-fetch.ts} +2 -3
  71. package/src/fetch/{types.js → types.ts} +5 -6
  72. package/src/fixtures/__tests__/{fixtures.test.js → fixtures.test.tsx} +6 -4
  73. package/src/fixtures/{fixtures.basic.stories.js → fixtures.basic.stories.tsx} +16 -13
  74. package/src/fixtures/{fixtures.defaultwrapper.stories.js → fixtures.defaultwrapper.stories.tsx} +8 -8
  75. package/src/fixtures/{fixtures.js → fixtures.tsx} +16 -11
  76. package/src/fixtures/{types.js → types.ts} +9 -13
  77. package/src/gql/__tests__/{gql-request-matches-mock.test.js → gql-request-matches-mock.test.ts} +17 -18
  78. package/src/gql/__tests__/{mock-gql-fetch.test.js → mock-gql-fetch.test.tsx} +44 -45
  79. package/src/gql/__tests__/{wb-data-integration.test.js → wb-data-integration.test.tsx} +21 -22
  80. package/src/gql/{gql-request-matches-mock.js → gql-request-matches-mock.ts} +1 -4
  81. package/src/gql/{mock-gql-fetch.js → mock-gql-fetch.ts} +3 -6
  82. package/src/gql/types.ts +33 -0
  83. package/src/harness/__tests__/{hook-harness.test.js → hook-harness.test.ts} +5 -6
  84. package/src/harness/__tests__/{make-hook-harness.test.js → make-hook-harness.test.tsx} +10 -11
  85. package/src/harness/__tests__/{make-test-harness.test.js → make-test-harness.test.tsx} +4 -5
  86. package/src/harness/__tests__/{render-adapters.test.js → render-adapters.test.tsx} +8 -9
  87. package/src/harness/__tests__/{test-harness.test.js → test-harness.test.ts} +5 -6
  88. package/src/harness/__tests__/{types.flowtest.js → types.flowtest.tsx} +24 -27
  89. package/src/harness/adapters/__tests__/{css.test.js → css.test.tsx} +2 -3
  90. package/src/harness/adapters/__tests__/{data.test.js → data.test.tsx} +4 -3
  91. package/src/harness/adapters/__tests__/{portal.test.js → portal.test.tsx} +0 -1
  92. package/src/harness/adapters/__tests__/{router.test.js → router.test.tsx} +75 -56
  93. package/src/harness/adapters/{adapters.js → adapters.ts} +1 -2
  94. package/src/harness/adapters/{css.js → css.tsx} +21 -18
  95. package/src/harness/adapters/{data.js → data.tsx} +7 -5
  96. package/src/harness/adapters/{portal.js → portal.tsx} +3 -4
  97. package/src/harness/adapters/router.tsx +218 -0
  98. package/src/harness/{hook-harness.js → hook-harness.ts} +2 -3
  99. package/src/harness/{make-hook-harness.js → make-hook-harness.ts} +6 -6
  100. package/src/harness/{make-test-harness.js → make-test-harness.tsx} +17 -20
  101. package/src/harness/{render-adapters.js → render-adapters.ts} +4 -4
  102. package/src/harness/{test-harness.js → test-harness.ts} +1 -12
  103. package/src/harness/{types.js → types.ts} +14 -12
  104. package/src/{index.js → index.ts} +0 -2
  105. package/src/{mock-requester.js → mock-requester.ts} +4 -3
  106. package/src/{respond-with.js → respond-with.ts} +42 -37
  107. package/src/{response-impl.js → response-impl.ts} +1 -2
  108. package/src/{settle-controller.js → settle-controller.ts} +9 -7
  109. package/src/{settle-signal.js → settle-signal.ts} +10 -7
  110. package/src/types.ts +40 -0
  111. package/tsconfig.json +11 -0
  112. package/tsconfig.tsbuildinfo +1 -0
  113. package/src/__docs__/_overview_.stories.mdx +0 -18
  114. package/src/__docs__/_overview_fixtures.stories.mdx +0 -18
  115. package/src/__docs__/_overview_mocking.stories.mdx +0 -14
  116. package/src/__docs__/_overview_test_harness.stories.mdx +0 -18
  117. package/src/__docs__/exports.fixtures.stories.mdx +0 -31
  118. package/src/__docs__/exports.harness-adapters.stories.mdx +0 -187
  119. package/src/__docs__/exports.hook-harness.stories.mdx +0 -22
  120. package/src/__docs__/exports.make-hook-harness.stories.mdx +0 -25
  121. package/src/__docs__/exports.make-test-harness.stories.mdx +0 -28
  122. package/src/__docs__/exports.mock-fetch.stories.mdx +0 -40
  123. package/src/__docs__/exports.mock-gql-fetch.stories.mdx +0 -64
  124. package/src/__docs__/exports.respond-with.stories.mdx +0 -84
  125. package/src/__docs__/exports.settle-controller.stories.mdx +0 -32
  126. package/src/__docs__/exports.test-harness.stories.mdx +0 -23
  127. package/src/__docs__/types.fetch-mock-fn.stories.mdx +0 -22
  128. package/src/__docs__/types.fetch-mock-operation.stories.mdx +0 -18
  129. package/src/__docs__/types.fixture-fn.stories.mdx +0 -46
  130. package/src/__docs__/types.fixture-props.stories.mdx +0 -20
  131. package/src/__docs__/types.get-props-options.stories.mdx +0 -52
  132. package/src/__docs__/types.gql-fetch-mock-fn.stories.mdx +0 -27
  133. package/src/__docs__/types.gql-mock-operation.stories.mdx +0 -26
  134. package/src/__docs__/types.mock-response.stories.mdx +0 -22
  135. package/src/__docs__/types.test-harness-adapter.stories.mdx +0 -21
  136. package/src/__docs__/types.test-harness-adapters.stories.mdx +0 -46
  137. package/src/__docs__/types.test-harness-config.stories.mdx +0 -18
  138. package/src/__docs__/types.test-harness-configs.stories.mdx +0 -59
  139. package/src/gql/types.js +0 -34
  140. package/src/harness/adapters/router.js +0 -206
  141. package/src/types.js +0 -39
  142. /package/src/harness/adapters/__tests__/__snapshots__/{router.test.js.snap → router.test.tsx.snap} +0 -0
@@ -1,14 +1,14 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
 
4
3
  import {fixtures} from "../index";
5
4
 
6
- type Props = {...};
5
+ type Props = Record<any, any>;
7
6
 
8
- const MyComponent = (props: Props) =>
9
- `My props: ${JSON.stringify(props, null, 2)}`;
7
+ const MyComponent: React.FC<Props> = (props): React.ReactElement => (
8
+ <>{`My props: ${JSON.stringify(props, null, 2)}`}</>
9
+ );
10
10
 
11
- const Wrapper = (props) => (
11
+ const Wrapper = (props: any) => (
12
12
  <>
13
13
  Wrapper &gt;&gt;&gt;
14
14
  <MyComponent {...props} />
@@ -16,7 +16,7 @@ const Wrapper = (props) => (
16
16
  </>
17
17
  );
18
18
 
19
- const DefaultWrapper = (props: Props): React.Node => (
19
+ const DefaultWrapper: React.FC<Props> = (props): React.ReactElement => (
20
20
  <>
21
21
  DefaultWrapper &gt;&gt;&gt;
22
22
  <MyComponent {...props} />
@@ -26,7 +26,7 @@ const DefaultWrapper = (props: Props): React.Node => (
26
26
 
27
27
  const fixture = fixtures(DefaultWrapper);
28
28
 
29
- export const F1: mixed = fixture(
29
+ export const F1: unknown = fixture(
30
30
  "This is a fixture with some regular props and the default wrapper",
31
31
  {
32
32
  see: "this is a prop",
@@ -34,7 +34,7 @@ export const F1: mixed = fixture(
34
34
  },
35
35
  );
36
36
 
37
- export const F2: mixed = fixture(
37
+ export const F2: unknown = fixture(
38
38
  "This fixture uses a custom wrapper",
39
39
  {
40
40
  just: "some props again",
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
  import {action} from "@storybook/addon-actions";
4
3
 
@@ -21,8 +20,11 @@ import type {FixtureFn, FixtureProps} from "./types";
21
20
  * ) => mixed} A function to create a CSF compatible story.
22
21
  */
23
22
  export const fixtures = <
24
- TComponent: React.ComponentType<any>,
25
- TProps: React.ElementConfig<TComponent>,
23
+ TComponent extends React.ComponentType<any>,
24
+ TProps extends JSX.LibraryManagedAttributes<
25
+ TComponent,
26
+ React.ComponentProps<TComponent>
27
+ >,
26
28
  >(
27
29
  Component: TComponent,
28
30
  ): FixtureFn<TProps> => {
@@ -31,18 +33,21 @@ export const fixtures = <
31
33
  let storyNumber = 1;
32
34
 
33
35
  const getPropsOptions = {
36
+ // @ts-expect-error [FEI-5019] - TS7006 - Parameter 'message' implicitly has an 'any' type. | TS7019 - Rest parameter 'args' implicitly has an 'any[]' type.
34
37
  log: (message, ...args) => action(message)(...args),
35
38
  logHandler: action,
36
- };
39
+ } as const;
37
40
 
38
41
  const makeStory = (
39
42
  description: string,
40
43
  props: FixtureProps<TProps>,
41
- wrapper: ?React.ComponentType<TProps> = null,
42
- ): mixed => {
44
+ wrapper: React.ComponentType<TProps> | null = null,
45
+ ): unknown => {
43
46
  const storyName = `${storyNumber++} ${description}`;
44
- const getProps = (options) =>
45
- typeof props === "function" ? props(options) : props;
47
+ const getProps = (options: {
48
+ log: (message: string, ...args: Array<any>) => any;
49
+ logHandler: any;
50
+ }) => (typeof props === "function" ? props(options) : props);
46
51
 
47
52
  const RealComponent = wrapper || Component;
48
53
 
@@ -52,10 +57,10 @@ export const fixtures = <
52
57
  // component. We don't use decorators for the wrapper
53
58
  // because we may not be in a storybook context and it
54
59
  // keeps the framework API simpler this way.
55
- let Template = templateMap.get((RealComponent: any));
60
+ let Template = templateMap.get(RealComponent as any);
56
61
  if (Template == null) {
57
- Template = (args) => <RealComponent {...args} />;
58
- templateMap.set((RealComponent: any), Template);
62
+ Template = (args: any) => <RealComponent {...args} />;
63
+ templateMap.set(RealComponent as any, Template);
59
64
  }
60
65
 
61
66
  // Each story that shares that component then reuses that
@@ -1,46 +1,42 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
 
4
3
  /**
5
4
  * Options injected to the function that returns the fixture props.
6
5
  */
7
- export type GetPropsOptions = {|
6
+ export type GetPropsOptions = {
8
7
  /**
9
8
  * A function to call that will log output.
10
9
  */
11
- log: (message: string, ...args: Array<any>) => void,
12
-
10
+ log: (message: string, ...args: Array<any>) => void;
13
11
  /**
14
12
  * A function to make a handler that will log all arguments with the given
15
13
  * name or message. Useful for logging events as it avoids the boilerplate
16
14
  * of the `log` function.
17
15
  */
18
- logHandler: (name: string) => (...args: Array<any>) => void,
19
- |};
16
+ logHandler: (name: string) => (...args: Array<any>) => void;
17
+ };
20
18
 
21
- export type FixtureProps<TProps: {...}> =
22
- | $ReadOnly<TProps>
23
- | ((options: $ReadOnly<GetPropsOptions>) => $ReadOnly<TProps>);
19
+ export type FixtureProps<TProps extends Record<any, any>> =
20
+ | Readonly<TProps>
21
+ | ((options: Readonly<GetPropsOptions>) => Readonly<TProps>);
24
22
 
25
23
  /**
26
24
  * A function for defining a fixture.
27
25
  */
28
- export type FixtureFn<TProps: {...}> = (
26
+ export type FixtureFn<TProps extends Record<any, any>> = (
29
27
  /**
30
28
  * The name of the fixture.
31
29
  */
32
30
  description: string,
33
-
34
31
  /**
35
32
  * The props for the fixture or a function that returns the props.
36
33
  * The function is injected with an API to facilitate logging.
37
34
  */
38
35
  props: FixtureProps<TProps>,
39
-
40
36
  /**
41
37
  * An alternative component to render for the fixture.
42
38
  * Useful if the fixture requires some additional setup for testing the
43
39
  * component.
44
40
  */
45
41
  wrapper?: React.ComponentType<TProps>,
46
- ) => mixed;
42
+ ) => unknown;
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import {gqlRequestMatchesMock} from "../gql-request-matches-mock";
3
2
 
4
3
  describe("#gqlRequestMatchesMock", () => {
@@ -9,11 +8,11 @@ describe("#gqlRequestMatchesMock", () => {
9
8
  id: "foo",
10
9
  type: "query",
11
10
  },
12
- };
11
+ } as const;
13
12
  const operation = {
14
13
  id: "foo",
15
14
  type: "mutation",
16
- };
15
+ } as const;
17
16
 
18
17
  // Act
19
18
  const result = gqlRequestMatchesMock(mock, operation, null, {});
@@ -29,7 +28,7 @@ describe("#gqlRequestMatchesMock", () => {
29
28
  id: "foo",
30
29
  type: "query",
31
30
  },
32
- };
31
+ } as const;
33
32
 
34
33
  // Act
35
34
  const result = gqlRequestMatchesMock(
@@ -48,7 +47,7 @@ describe("#gqlRequestMatchesMock", () => {
48
47
 
49
48
  it.each([{foo: "bar"}, {foo: "baz", anExtra: "property"}, null])(
50
49
  "should return false if variables don't match",
51
- (variables) => {
50
+ (variables: any) => {
52
51
  // Arrange
53
52
  const mock = {
54
53
  operation: {
@@ -58,11 +57,11 @@ describe("#gqlRequestMatchesMock", () => {
58
57
  variables: {
59
58
  foo: "baz",
60
59
  },
61
- };
60
+ } as const;
62
61
  const operation = {
63
62
  id: "foo",
64
63
  type: "query",
65
- };
64
+ } as const;
66
65
 
67
66
  // Act
68
67
  const result = gqlRequestMatchesMock(
@@ -79,7 +78,7 @@ describe("#gqlRequestMatchesMock", () => {
79
78
 
80
79
  it.each([{a: "context"}, null])(
81
80
  "should return false if contexts don't match",
82
- (context) => {
81
+ (context: any) => {
83
82
  // Arrange
84
83
  const mock = {
85
84
  operation: {
@@ -92,14 +91,14 @@ describe("#gqlRequestMatchesMock", () => {
92
91
  context: {
93
92
  mock: "context",
94
93
  },
95
- };
94
+ } as const;
96
95
  const operation = {
97
96
  id: "foo",
98
97
  type: "query",
99
- };
98
+ } as const;
100
99
  const variables = {
101
100
  foo: "bar",
102
- };
101
+ } as const;
103
102
 
104
103
  // Act
105
104
  const result = gqlRequestMatchesMock(
@@ -121,7 +120,7 @@ describe("#gqlRequestMatchesMock", () => {
121
120
  id: "foo",
122
121
  type: "query",
123
122
  },
124
- };
123
+ } as const;
125
124
 
126
125
  // Act
127
126
  const result = gqlRequestMatchesMock(
@@ -148,7 +147,7 @@ describe("#gqlRequestMatchesMock", () => {
148
147
  variables: {
149
148
  foo: "bar",
150
149
  },
151
- };
150
+ } as const;
152
151
 
153
152
  // Act
154
153
  const result = gqlRequestMatchesMock(
@@ -177,7 +176,7 @@ describe("#gqlRequestMatchesMock", () => {
177
176
  context: {
178
177
  foo: "bar",
179
178
  },
180
- };
179
+ } as const;
181
180
 
182
181
  // Act
183
182
  const result = gqlRequestMatchesMock(
@@ -209,17 +208,17 @@ describe("#gqlRequestMatchesMock", () => {
209
208
  context: {
210
209
  foo: "bar",
211
210
  },
212
- };
211
+ } as const;
213
212
  const operation = {
214
213
  id: "foo",
215
214
  type: "query",
216
- };
215
+ } as const;
217
216
  const variables = {
218
217
  foo: "bar",
219
- };
218
+ } as const;
220
219
  const context = {
221
220
  foo: "bar",
222
- };
221
+ } as const;
223
222
 
224
223
  // Act
225
224
  const result = gqlRequestMatchesMock(
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
  import {render, screen, waitFor} from "@testing-library/react";
4
3
 
@@ -12,13 +11,13 @@ describe("#mockGqlFetch", () => {
12
11
  // Arrange
13
12
  const mockFetch = mockGqlFetch();
14
13
  const RenderError = () => {
15
- const [result, setResult] = React.useState(null);
14
+ const [result, setResult] = React.useState<any>(null);
16
15
  const gqlFetch = useGql();
17
16
  React.useEffect(() => {
18
17
  gqlFetch({
19
18
  type: "query",
20
19
  id: "getMyStuff",
21
- }).catch((e) => {
20
+ }).catch((e: any) => {
22
21
  setResult(e.message);
23
22
  });
24
23
  }, [gqlFetch]);
@@ -48,14 +47,14 @@ describe("#mockGqlFetch", () => {
48
47
  const query = {
49
48
  type: "query",
50
49
  id: "getMyStuff",
51
- };
52
- const data = {myStuff: "stuff"};
50
+ } as const;
51
+ const data = {myStuff: "stuff"} as const;
53
52
  const RenderData = () => {
54
- const [result, setResult] = React.useState(null);
53
+ const [result, setResult] = React.useState<any>(null);
55
54
  const gqlFetch = useGql();
56
55
  React.useEffect(() => {
57
56
  // eslint-disable-next-line promise/catch-or-return
58
- gqlFetch(query).then((r) => {
57
+ gqlFetch(query).then((r: any) => {
59
58
  setResult(JSON.stringify(r ?? "(null)"));
60
59
  return;
61
60
  });
@@ -88,13 +87,13 @@ describe("#mockGqlFetch", () => {
88
87
  const query = {
89
88
  type: "query",
90
89
  id: "getMyStuff",
91
- };
90
+ } as const;
92
91
  const RenderError = () => {
93
- const [result, setResult] = React.useState(null);
92
+ const [result, setResult] = React.useState<any>(null);
94
93
  const gqlFetch = useGql();
95
94
  React.useEffect(() => {
96
95
  // eslint-disable-next-line promise/catch-or-return
97
- gqlFetch(query).catch((e) => {
96
+ gqlFetch(query).catch((e: any) => {
98
97
  setResult(e.message);
99
98
  return;
100
99
  });
@@ -125,13 +124,13 @@ describe("#mockGqlFetch", () => {
125
124
  const query = {
126
125
  type: "query",
127
126
  id: "getMyStuff",
128
- };
127
+ } as const;
129
128
  const RenderError = () => {
130
- const [result, setResult] = React.useState(null);
129
+ const [result, setResult] = React.useState<any>(null);
131
130
  const gqlFetch = useGql();
132
131
  React.useEffect(() => {
133
132
  // eslint-disable-next-line promise/catch-or-return
134
- gqlFetch(query).catch((e) => {
133
+ gqlFetch(query).catch((e: any) => {
135
134
  setResult(e.message);
136
135
  });
137
136
  }, [gqlFetch]);
@@ -176,10 +175,10 @@ describe("#mockGqlFetch", () => {
176
175
  await expect(result).rejects.toThrowErrorMatchingInlineSnapshot(`
177
176
  "No matching mock response found for request:
178
177
  Operation: query getMyStuff
179
- Variables: {
178
+ Variables: {
180
179
  "a": "variable"
181
180
  }
182
- Context: {
181
+ Context: {
183
182
  "my": "context"
184
183
  }"
185
184
  `);
@@ -192,10 +191,10 @@ describe("#mockGqlFetch", () => {
192
191
  const operation = {
193
192
  type: "query",
194
193
  id: "getMyStuff",
195
- };
194
+ } as const;
196
195
  const data = {
197
196
  myStuff: "stuff",
198
- };
197
+ } as const;
199
198
 
200
199
  // Act
201
200
  mockFetch.mockOperation({operation}, RespondWith.graphQLData(data));
@@ -215,10 +214,10 @@ describe("#mockGqlFetch", () => {
215
214
  const operation = {
216
215
  type: "query",
217
216
  id: "getMyStuff",
218
- };
217
+ } as const;
219
218
  const data = {
220
219
  myStuff: "stuff",
221
- };
220
+ } as const;
222
221
 
223
222
  // Act
224
223
  mockFetch.mockOperation({operation}, RespondWith.graphQLData(data));
@@ -238,13 +237,13 @@ describe("#mockGqlFetch", () => {
238
237
  const operation = {
239
238
  type: "query",
240
239
  id: "getMyStuff",
241
- };
240
+ } as const;
242
241
  const variables = {
243
242
  a: "variable",
244
- };
243
+ } as const;
245
244
  const data = {
246
245
  myStuff: "stuff",
247
- };
246
+ } as const;
248
247
 
249
248
  // Act
250
249
  mockFetch.mockOperation(
@@ -263,13 +262,13 @@ describe("#mockGqlFetch", () => {
263
262
  const operation = {
264
263
  type: "query",
265
264
  id: "getMyStuff",
266
- };
265
+ } as const;
267
266
  const variables = {
268
267
  a: "variable",
269
- };
268
+ } as const;
270
269
  const data = {
271
270
  myStuff: "stuff",
272
- };
271
+ } as const;
273
272
 
274
273
  // Act
275
274
  mockFetch.mockOperation(
@@ -292,13 +291,13 @@ describe("#mockGqlFetch", () => {
292
291
  const operation = {
293
292
  type: "query",
294
293
  id: "getMyStuff",
295
- };
294
+ } as const;
296
295
  const context = {
297
296
  my: "context",
298
- };
297
+ } as const;
299
298
  const data = {
300
299
  myStuff: "stuff",
301
- };
300
+ } as const;
302
301
 
303
302
  // Act
304
303
  mockFetch.mockOperation(
@@ -317,13 +316,13 @@ describe("#mockGqlFetch", () => {
317
316
  const operation = {
318
317
  type: "query",
319
318
  id: "getMyStuff",
320
- };
319
+ } as const;
321
320
  const context = {
322
321
  my: "context",
323
- };
322
+ } as const;
324
323
  const data = {
325
324
  myStuff: "stuff",
326
- };
325
+ } as const;
327
326
 
328
327
  // Act
329
328
  mockFetch.mockOperation(
@@ -346,16 +345,16 @@ describe("#mockGqlFetch", () => {
346
345
  const operation = {
347
346
  type: "query",
348
347
  id: "getMyStuff",
349
- };
348
+ } as const;
350
349
  const variables = {
351
350
  a: "variable",
352
- };
351
+ } as const;
353
352
  const context = {
354
353
  my: "context",
355
- };
354
+ } as const;
356
355
  const data = {
357
356
  myStuff: "stuff",
358
- };
357
+ } as const;
359
358
 
360
359
  // Act
361
360
  mockFetch.mockOperation(
@@ -374,16 +373,16 @@ describe("#mockGqlFetch", () => {
374
373
  const operation = {
375
374
  type: "query",
376
375
  id: "getMyStuff",
377
- };
376
+ } as const;
378
377
  const variables = {
379
378
  a: "variable",
380
- };
379
+ } as const;
381
380
  const context = {
382
381
  my: "context",
383
- };
382
+ } as const;
384
383
  const data = {
385
384
  myStuff: "stuff",
386
- };
385
+ } as const;
387
386
 
388
387
  // Act
389
388
  mockFetch.mockOperation(
@@ -403,10 +402,10 @@ describe("#mockGqlFetch", () => {
403
402
  const operation = {
404
403
  type: "query",
405
404
  id: "getMyStuff",
406
- };
405
+ } as const;
407
406
  const data = {
408
407
  myStuff: "stuff",
409
- };
408
+ } as const;
410
409
 
411
410
  // Act
412
411
  mockFetch.mockOperation({operation}, RespondWith.graphQLData(data));
@@ -430,10 +429,10 @@ describe("#mockGqlFetch", () => {
430
429
  const operation = {
431
430
  type: "query",
432
431
  id: "getMyStuff",
433
- };
432
+ } as const;
434
433
  const data = {
435
434
  myStuff: "stuff",
436
- };
435
+ } as const;
437
436
 
438
437
  // Act
439
438
  mockFetch.mockOperationOnce(
@@ -456,10 +455,10 @@ describe("#mockGqlFetch", () => {
456
455
  const operation = {
457
456
  type: "query",
458
457
  id: "getMyStuff",
459
- };
458
+ } as const;
460
459
  const data = {
461
460
  myStuff: "stuff",
462
- };
461
+ } as const;
463
462
 
464
463
  // Act
465
464
  mockFetch.mockOperationOnce(
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
  import {render, screen, waitFor} from "@testing-library/react";
4
3
 
@@ -11,13 +10,13 @@ describe("integrating mockGqlFetch, RespondWith, GqlRouter and useGql", () => {
11
10
  // Arrange
12
11
  const mockFetch = mockGqlFetch();
13
12
  const RenderError = () => {
14
- const [result, setResult] = React.useState(null);
13
+ const [result, setResult] = React.useState<any>(null);
15
14
  const gqlFetch = useGql();
16
15
  React.useEffect(() => {
17
16
  gqlFetch({
18
17
  type: "query",
19
18
  id: "getMyStuff",
20
- }).catch((e) => {
19
+ }).catch((e: any) => {
21
20
  setResult(e.message);
22
21
  });
23
22
  }, [gqlFetch]);
@@ -47,14 +46,14 @@ describe("integrating mockGqlFetch, RespondWith, GqlRouter and useGql", () => {
47
46
  const query = {
48
47
  type: "query",
49
48
  id: "getMyStuff",
50
- };
51
- const data = {myStuff: "stuff"};
49
+ } as const;
50
+ const data = {myStuff: "stuff"} as const;
52
51
  const RenderData = () => {
53
- const [result, setResult] = React.useState(null);
52
+ const [result, setResult] = React.useState<any>(null);
54
53
  const gqlFetch = useGql();
55
54
  React.useEffect(() => {
56
55
  // eslint-disable-next-line promise/catch-or-return
57
- gqlFetch(query).then((r) => {
56
+ gqlFetch(query).then((r: any) => {
58
57
  setResult(JSON.stringify(r ?? "(null)"));
59
58
  return;
60
59
  });
@@ -87,13 +86,13 @@ describe("integrating mockGqlFetch, RespondWith, GqlRouter and useGql", () => {
87
86
  const query = {
88
87
  type: "query",
89
88
  id: "getMyStuff",
90
- };
89
+ } as const;
91
90
  const RenderError = () => {
92
- const [result, setResult] = React.useState(null);
91
+ const [result, setResult] = React.useState<any>(null);
93
92
  const gqlFetch = useGql();
94
93
  React.useEffect(() => {
95
94
  // eslint-disable-next-line promise/catch-or-return
96
- gqlFetch(query).catch((e) => {
95
+ gqlFetch(query).catch((e: any) => {
97
96
  setResult(e.message);
98
97
  return;
99
98
  });
@@ -124,13 +123,13 @@ describe("integrating mockGqlFetch, RespondWith, GqlRouter and useGql", () => {
124
123
  const query = {
125
124
  type: "query",
126
125
  id: "getMyStuff",
127
- };
126
+ } as const;
128
127
  const RenderError = () => {
129
- const [result, setResult] = React.useState(null);
128
+ const [result, setResult] = React.useState<any>(null);
130
129
  const gqlFetch = useGql();
131
130
  React.useEffect(() => {
132
131
  // eslint-disable-next-line promise/catch-or-return
133
- gqlFetch(query).catch((e) => {
132
+ gqlFetch(query).catch((e: any) => {
134
133
  setResult(e.message);
135
134
  });
136
135
  }, [gqlFetch]);
@@ -162,13 +161,13 @@ describe("integrating mockGqlFetch, RespondWith, GqlRouter and useGql", () => {
162
161
  const query = {
163
162
  type: "query",
164
163
  id: "getMyStuff",
165
- };
164
+ } as const;
166
165
  const RenderError = () => {
167
- const [result, setResult] = React.useState(null);
166
+ const [result, setResult] = React.useState<any>(null);
168
167
  const gqlFetch = useGql();
169
168
  React.useEffect(() => {
170
169
  // eslint-disable-next-line promise/catch-or-return
171
- gqlFetch(query).catch((e) => {
170
+ gqlFetch(query).catch((e: any) => {
172
171
  setResult(e.message);
173
172
  });
174
173
  }, [gqlFetch]);
@@ -200,13 +199,13 @@ describe("integrating mockGqlFetch, RespondWith, GqlRouter and useGql", () => {
200
199
  const query = {
201
200
  type: "query",
202
201
  id: "getMyStuff",
203
- };
202
+ } as const;
204
203
  const RenderError = () => {
205
- const [result, setResult] = React.useState(null);
204
+ const [result, setResult] = React.useState<any>(null);
206
205
  const gqlFetch = useGql();
207
206
  React.useEffect(() => {
208
207
  // eslint-disable-next-line promise/catch-or-return
209
- gqlFetch(query).catch((e) => {
208
+ gqlFetch(query).catch((e: any) => {
210
209
  setResult(e.message);
211
210
  });
212
211
  }, [gqlFetch]);
@@ -238,13 +237,13 @@ describe("integrating mockGqlFetch, RespondWith, GqlRouter and useGql", () => {
238
237
  const query = {
239
238
  type: "query",
240
239
  id: "getMyStuff",
241
- };
240
+ } as const;
242
241
  const RenderError = () => {
243
- const [result, setResult] = React.useState(null);
242
+ const [result, setResult] = React.useState<any>(null);
244
243
  const gqlFetch = useGql();
245
244
  React.useEffect(() => {
246
245
  // eslint-disable-next-line promise/catch-or-return
247
- gqlFetch(query).catch((e) => {
246
+ gqlFetch(query).catch((e: any) => {
248
247
  setResult(e.message);
249
248
  });
250
249
  }, [gqlFetch]);