@khanacademy/wonder-blocks-testing 7.1.9 → 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 (147) hide show
  1. package/CHANGELOG.md +36 -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} +3 -4
  62. package/src/__tests__/{respond-with.test.js → respond-with.test.ts} +2 -3
  63. package/src/__tests__/response-impl.test.js +3 -3
  64. package/src/__tests__/{settle-controller.test.js → settle-controller.test.ts} +2 -3
  65. package/src/__tests__/{settle-signal.test.js → settle-signal.test.ts} +1 -2
  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} +6 -7
  68. package/src/fetch/__tests__/{mock-fetch.test.js → mock-fetch.test.ts} +3 -4
  69. package/src/fetch/{fetch-request-matches-mock.js → fetch-request-matches-mock.ts} +4 -3
  70. package/src/fetch/{mock-fetch.js → mock-fetch.ts} +5 -6
  71. package/src/fetch/types.ts +14 -0
  72. package/src/fixtures/__tests__/{fixtures.test.js → fixtures.test.tsx} +7 -5
  73. package/src/fixtures/{fixtures.basic.stories.js → fixtures.basic.stories.tsx} +17 -14
  74. package/src/fixtures/{fixtures.defaultwrapper.stories.js → fixtures.defaultwrapper.stories.tsx} +9 -9
  75. package/src/fixtures/{fixtures.js → fixtures.tsx} +17 -12
  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} +18 -19
  78. package/src/gql/__tests__/{mock-gql-fetch.test.js → mock-gql-fetch.test.tsx} +46 -47
  79. package/src/gql/__tests__/{wb-data-integration.test.js → wb-data-integration.test.tsx} +23 -24
  80. package/src/gql/{gql-request-matches-mock.js → gql-request-matches-mock.ts} +2 -5
  81. package/src/gql/mock-gql-fetch.ts +15 -0
  82. package/src/gql/types.ts +33 -0
  83. package/src/harness/__tests__/{hook-harness.test.js → hook-harness.test.ts} +13 -14
  84. package/src/harness/__tests__/{make-hook-harness.test.js → make-hook-harness.test.tsx} +12 -13
  85. package/src/harness/__tests__/{make-test-harness.test.js → make-test-harness.test.tsx} +7 -8
  86. package/src/harness/__tests__/{render-adapters.test.js → render-adapters.test.tsx} +10 -11
  87. package/src/harness/__tests__/{test-harness.test.js → test-harness.test.ts} +13 -14
  88. package/src/harness/__tests__/{types.flowtest.js → types.flowtest.tsx} +25 -28
  89. package/src/harness/adapters/__tests__/{css.test.js → css.test.tsx} +3 -4
  90. package/src/harness/adapters/__tests__/{data.test.js → data.test.tsx} +5 -4
  91. package/src/harness/adapters/__tests__/{portal.test.js → portal.test.tsx} +1 -2
  92. package/src/harness/adapters/__tests__/{router.test.js → router.test.tsx} +76 -57
  93. package/src/harness/adapters/{adapters.js → adapters.ts} +6 -7
  94. package/src/harness/adapters/{css.js → css.tsx} +22 -19
  95. package/src/harness/adapters/{data.js → data.tsx} +8 -6
  96. package/src/harness/adapters/{portal.js → portal.tsx} +4 -5
  97. package/src/harness/adapters/router.tsx +218 -0
  98. package/src/harness/{hook-harness.js → hook-harness.ts} +5 -6
  99. package/src/harness/{make-hook-harness.js → make-hook-harness.ts} +8 -8
  100. package/src/harness/{make-test-harness.js → make-test-harness.tsx} +19 -22
  101. package/src/harness/{render-adapters.js → render-adapters.ts} +5 -5
  102. package/src/harness/test-harness.ts +13 -0
  103. package/src/harness/{types.js → types.ts} +14 -12
  104. package/src/index.ts +20 -0
  105. package/src/{mock-requester.js → mock-requester.ts} +6 -5
  106. package/src/{respond-with.js → respond-with.ts} +45 -40
  107. package/src/{response-impl.js → response-impl.ts} +1 -2
  108. package/src/settle-controller.ts +37 -0
  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/fetch/types.js +0 -15
  140. package/src/gql/mock-gql-fetch.js +0 -18
  141. package/src/gql/types.js +0 -34
  142. package/src/harness/adapters/router.js +0 -206
  143. package/src/harness/test-harness.js +0 -24
  144. package/src/index.js +0 -26
  145. package/src/settle-controller.js +0 -35
  146. package/src/types.js +0 -39
  147. /package/src/harness/adapters/__tests__/__snapshots__/{router.test.js.snap → router.test.tsx.snap} +0 -0
@@ -1,8 +1,7 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
  import {render, screen} from "@testing-library/react";
4
3
 
5
- import * as Css from "../css.js";
4
+ import * as Css from "../css";
6
5
 
7
6
  describe("Css.adapter", () => {
8
7
  it("should throw if the config is invalid", () => {
@@ -62,7 +61,7 @@ describe("Css.adapter", () => {
62
61
  ${{classes: ["class1", "class2"], style: {backgroundColor: "red"}}} | ${"class1 class2"}
63
62
  `(
64
63
  "should apply the given class names from $config to the container element",
65
- ({config, expectation}) => {
64
+ ({config, expectation}: any) => {
66
65
  // Arrange
67
66
  const children = <div data-test-id="children">CHILDREN!</div>;
68
67
 
@@ -81,7 +80,7 @@ describe("Css.adapter", () => {
81
80
  ${{style: {backgroundColor: "red"}, classes: []}} | ${{backgroundColor: "red"}}
82
81
  `(
83
82
  "should apply the given styles from $config to the container element",
84
- ({config, expectation}) => {
83
+ ({config, expectation}: any) => {
85
84
  // Arrange
86
85
  const children = <div data-test-id="children">CHILDREN!</div>;
87
86
 
@@ -1,8 +1,7 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
  import {render, screen, waitFor} from "@testing-library/react";
4
3
  import {useCachedEffect} from "@khanacademy/wonder-blocks-data";
5
- import * as Data from "../data.js";
4
+ import * as Data from "../data";
6
5
 
7
6
  describe("WonderBlocksData.adapter", () => {
8
7
  it("should render children when configuration arrays are empty", () => {
@@ -22,13 +21,14 @@ describe("WonderBlocksData.adapter", () => {
22
21
  const TestFixture = () => {
23
22
  const [result] = useCachedEffect("ID", jest.fn());
24
23
 
24
+ // @ts-expect-error [FEI-5019] - TS2339 - Property 'data' does not exist on type 'Result<ValidCacheData>'.
25
25
  return <div>CONTENT: {result?.data}</div>;
26
26
  };
27
27
 
28
28
  // Act
29
29
  const {container} = render(
30
30
  Data.adapter(<TestFixture />, () =>
31
- Promise.resolve(("INTERCEPTED!": any)),
31
+ Promise.resolve("INTERCEPTED!" as any),
32
32
  ),
33
33
  );
34
34
 
@@ -43,13 +43,14 @@ describe("WonderBlocksData.adapter", () => {
43
43
  const TestFixture = () => {
44
44
  const [result] = useCachedEffect("ID", jest.fn());
45
45
 
46
+ // @ts-expect-error [FEI-5019] - TS2339 - Property 'data' does not exist on type 'Result<ValidCacheData>'.
46
47
  return <div>CONTENT:{result?.data}</div>;
47
48
  };
48
49
 
49
50
  // Act
50
51
  const {container} = render(
51
52
  Data.adapter(<TestFixture />, () =>
52
- Promise.resolve(("INTERCEPTED!": any)),
53
+ Promise.resolve("INTERCEPTED!" as any),
53
54
  ),
54
55
  );
55
56
 
@@ -1,8 +1,7 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
  import {render, screen} from "@testing-library/react";
4
3
 
5
- import * as Portal from "../portal.js";
4
+ import * as Portal from "../portal";
6
5
 
7
6
  describe("Portal.adapter", () => {
8
7
  it("should render a portal root element", () => {
@@ -1,8 +1,7 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
  import {withRouter, Prompt} from "react-router-dom";
4
3
  import {render} from "@testing-library/react";
5
- import * as Router from "../router.js";
4
+ import * as Router from "../router";
6
5
 
7
6
  describe("Router.adapter", () => {
8
7
  it("should throw if the config does not match any expecations", () => {
@@ -25,17 +24,22 @@ describe("Router.adapter", () => {
25
24
  ${"string"} | ${"/math"}
26
25
  ${"location"} | ${{location: "/math"}}
27
26
  ${"full"} | ${{initialEntries: ["/math"]}}
28
- `("with $type config", ({config}) => {
27
+ `("with $type config", ({config}: any) => {
29
28
  it("should allow navigation", () => {
30
29
  // Arrange
31
30
  const historyListen = jest.fn();
32
- const HistoryListener = withRouter(({history}): React.Node => {
33
- React.useEffect(() => history.listen(historyListen), [history]);
34
- if (history.location.pathname === "/math") {
35
- history.push("/math/calculator");
36
- }
37
- return null;
38
- });
31
+ const HistoryListener = withRouter(
32
+ ({history}: any): React.ReactElement | null => {
33
+ React.useEffect(
34
+ () => history.listen(historyListen),
35
+ [history],
36
+ );
37
+ if (history.location.pathname === "/math") {
38
+ history.push("/math/calculator");
39
+ }
40
+ return null;
41
+ },
42
+ );
39
43
 
40
44
  // Act
41
45
  render(Router.adapter(<HistoryListener />, config));
@@ -47,15 +51,17 @@ describe("Router.adapter", () => {
47
51
  it("should have default route match of root /", () => {
48
52
  // Arrange
49
53
  const matchCatcherFn = jest.fn();
50
- const MatchCatcher = withRouter(({match, history}): React.Node => {
51
- React.useEffect(() => {
52
- if (history.location.pathname === "/math") {
53
- history.push("/math/calculator");
54
- }
55
- matchCatcherFn(match);
56
- }, [match, history]);
57
- return null;
58
- });
54
+ const MatchCatcher = withRouter(
55
+ ({match, history}: any): React.ReactElement | null => {
56
+ React.useEffect(() => {
57
+ if (history.location.pathname === "/math") {
58
+ history.push("/math/calculator");
59
+ }
60
+ matchCatcherFn(match);
61
+ }, [match, history]);
62
+ return null;
63
+ },
64
+ );
59
65
 
60
66
  // Act
61
67
  render(Router.adapter(<MatchCatcher />, config));
@@ -74,16 +80,18 @@ describe("Router.adapter", () => {
74
80
  type | config
75
81
  ${"location"} | ${{location: "/math/calculator", path: "/math/*"}}
76
82
  ${"full"} | ${{initialEntries: ["/math/calculator"], path: "/math/*"}}
77
- `("with $type config including path", ({config}) => {
83
+ `("with $type config including path", ({config}: any) => {
78
84
  it("should include routing for the given path", () => {
79
85
  // Arrange
80
86
  const matchCatcherFn = jest.fn();
81
- const MatchCatcher = withRouter(({match}): React.Node => {
82
- React.useEffect(() => {
83
- matchCatcherFn(match);
84
- }, [match]);
85
- return null;
86
- });
87
+ const MatchCatcher = withRouter(
88
+ ({match}: any): React.ReactElement | null => {
89
+ React.useEffect(() => {
90
+ matchCatcherFn(match);
91
+ }, [match]);
92
+ return null;
93
+ },
94
+ );
87
95
 
88
96
  // Act
89
97
  render(Router.adapter(<MatchCatcher />, config));
@@ -106,7 +114,7 @@ describe("Router.adapter", () => {
106
114
  const badConfig = {
107
115
  ...config,
108
116
  path: "/something/else/entirely",
109
- };
117
+ } as const;
110
118
 
111
119
  // Act
112
120
  const underTest = () =>
@@ -121,13 +129,18 @@ describe("Router.adapter", () => {
121
129
  it("should not navigate", () => {
122
130
  // Arrange
123
131
  const historyListen = jest.fn();
124
- const HistoryListener = withRouter(({history}): React.Node => {
125
- React.useEffect(() => history.listen(historyListen), [history]);
126
- if (history.location.pathname === "/math") {
127
- history.push("/math/calculator");
128
- }
129
- return null;
130
- });
132
+ const HistoryListener = withRouter(
133
+ ({history}: any): React.ReactElement | null => {
134
+ React.useEffect(
135
+ () => history.listen(historyListen),
136
+ [history],
137
+ );
138
+ if (history.location.pathname === "/math") {
139
+ history.push("/math/calculator");
140
+ }
141
+ return null;
142
+ },
143
+ );
131
144
 
132
145
  // Act
133
146
  render(
@@ -146,12 +159,14 @@ describe("Router.adapter", () => {
146
159
  it("should use the defaultConfig location if initialEntries is empty", () => {
147
160
  // Arrange
148
161
  const matchCatcherFn = jest.fn();
149
- const MatchCatcher = withRouter(({match, history}): React.Node => {
150
- React.useEffect(() => {
151
- matchCatcherFn(match);
152
- }, [match, history]);
153
- return null;
154
- });
162
+ const MatchCatcher = withRouter(
163
+ ({match, history}: any): React.ReactElement | null => {
164
+ React.useEffect(() => {
165
+ matchCatcherFn(match);
166
+ }, [match, history]);
167
+ return null;
168
+ },
169
+ );
155
170
 
156
171
  // Act
157
172
  render(
@@ -171,12 +186,14 @@ describe("Router.adapter", () => {
171
186
  it("should set initialIndex prop on MemoryRouter if given in configuration", () => {
172
187
  // Arrange
173
188
  const matchCatcherFn = jest.fn();
174
- const MatchCatcher = withRouter(({match}): React.Node => {
175
- React.useEffect(() => {
176
- matchCatcherFn(match);
177
- }, [match]);
178
- return null;
179
- });
189
+ const MatchCatcher = withRouter(
190
+ ({match}: any): React.ReactElement | null => {
191
+ React.useEffect(() => {
192
+ matchCatcherFn(match);
193
+ }, [match]);
194
+ return null;
195
+ },
196
+ );
180
197
 
181
198
  // Act
182
199
  render(
@@ -199,20 +216,22 @@ describe("Router.adapter", () => {
199
216
  // Arrange
200
217
  const getUserConfirmationSpy = jest
201
218
  .fn()
202
- .mockImplementation((message, cb) => {
219
+ .mockImplementation((message: any, cb: any) => {
203
220
  cb(true);
204
221
  });
205
222
  const matchCatcherFn = jest.fn();
206
- const MatchCatcher = withRouter(({match, history}): React.Node => {
207
- React.useEffect(() => {
208
- if (history.location.pathname === "/location/old") {
209
- // Fire off a location change.
210
- history.goForward();
211
- }
212
- matchCatcherFn(match);
213
- }, [match, history]);
214
- return <Prompt message="Are you sure?" />;
215
- });
223
+ const MatchCatcher = withRouter(
224
+ ({match, history}: any): React.ReactElement => {
225
+ React.useEffect(() => {
226
+ if (history.location.pathname === "/location/old") {
227
+ // Fire off a location change.
228
+ history.goForward();
229
+ }
230
+ matchCatcherFn(match);
231
+ }, [match, history]);
232
+ return <Prompt message="Are you sure?" />;
233
+ },
234
+ );
216
235
 
217
236
  // Act
218
237
  render(
@@ -1,10 +1,9 @@
1
- // @flow
2
- import * as css from "./css.js";
3
- import * as data from "./data.js";
4
- import * as portal from "./portal.js";
5
- import * as router from "./router.js";
1
+ import * as css from "./css";
2
+ import * as data from "./data";
3
+ import * as portal from "./portal";
4
+ import * as router from "./router";
6
5
 
7
- import type {TestHarnessConfigs} from "../types.js";
6
+ import type {TestHarnessConfigs} from "../types";
8
7
 
9
8
  /**
10
9
  * NOTE: We do not type `DefaultAdapters` with `Adapters` here because we want
@@ -20,7 +19,7 @@ export const DefaultAdapters = {
20
19
  data: data.adapter,
21
20
  portal: portal.adapter,
22
21
  router: router.adapter,
23
- };
22
+ } as const;
24
23
 
25
24
  /**
26
25
  * The default configurations to use with the `DefaultAdapters`.
@@ -1,44 +1,47 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
 
4
3
  import type {CSSProperties} from "aphrodite";
5
4
 
6
- import type {TestHarnessAdapter} from "../types.js";
5
+ import type {TestHarnessAdapter} from "../types";
7
6
 
8
7
  type Config =
9
8
  | string
10
9
  | Array<string>
11
10
  | CSSProperties
12
- | {|
13
- classes: Array<string>,
14
- style: CSSProperties,
15
- |};
11
+ | {
12
+ classes: Array<string>;
13
+ style: CSSProperties;
14
+ };
16
15
 
17
16
  // The default configuration is to omit this adapter.
18
- export const defaultConfig: ?Config = null;
17
+ export const defaultConfig: Config | null | undefined = null;
19
18
 
20
19
  const normalizeConfig = (
21
20
  config: Config,
22
- ): {|classes: Array<string>, style: CSSProperties|} => {
21
+ ): {
22
+ classes: Array<string>;
23
+ style: CSSProperties;
24
+ } => {
23
25
  if (typeof config === "string") {
24
- return {classes: [config], style: ({}: $Shape<CSSProperties>)};
26
+ return {classes: [config], style: {} as Partial<CSSProperties>};
25
27
  }
26
28
 
27
29
  if (Array.isArray(config)) {
28
- return {classes: config, style: ({}: $Shape<CSSProperties>)};
30
+ return {classes: config, style: {} as Partial<CSSProperties>};
29
31
  }
30
32
 
31
33
  if (typeof config === "object") {
32
- if (config.classes != null && config.style != null) {
33
- // This is a heuristic check and by nature isn't perfect.
34
- // So we have to tell flow to just accept it.
35
- // $FlowIgnore[prop-missing]
34
+ if (
35
+ "classes" in config &&
36
+ config.classes != null &&
37
+ "style" in config &&
38
+ config.style != null
39
+ ) {
36
40
  return config;
37
41
  }
38
42
 
39
- // Again, since the previous check is heuristic, so is this outcome
40
- // and so we still have to assure flow everything is OK.
41
- // $FlowIgnore[prop-missing]
43
+ // @ts-expect-error: at this point, `CSSProperties` is the only thing
44
+ // that `config` can be.
42
45
  return {classes: [], style: config};
43
46
  }
44
47
 
@@ -49,9 +52,9 @@ const normalizeConfig = (
49
52
  * Test harness adapter for adding CSS to the harnessed component wrapper.
50
53
  */
51
54
  export const adapter: TestHarnessAdapter<Config> = (
52
- children: React.Node,
55
+ children: React.ReactNode,
53
56
  config: Config,
54
- ): React.Element<any> => {
57
+ ): React.ReactElement<any> => {
55
58
  const {classes, style} = normalizeConfig(config);
56
59
  return (
57
60
  <div
@@ -1,16 +1,18 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
  import {InterceptRequests} from "@khanacademy/wonder-blocks-data";
4
- import type {TestHarnessAdapter} from "../types.js";
3
+ import type {TestHarnessAdapter} from "../types";
5
4
 
6
- type Interceptor = React.ElementConfig<typeof InterceptRequests>["interceptor"];
5
+ type Interceptor = JSX.LibraryManagedAttributes<
6
+ typeof InterceptRequests,
7
+ React.ComponentProps<typeof InterceptRequests>
8
+ >["interceptor"];
7
9
 
8
10
  type Config = Interceptor | Array<Interceptor>;
9
11
 
10
12
  /**
11
13
  * Default configuration for the Wonder Blocks Data adapter.
12
14
  */
13
- export const defaultConfig = ([]: Array<Interceptor>);
15
+ export const defaultConfig = [] as Array<Interceptor>;
14
16
 
15
17
  /**
16
18
  * Test harness adapter to mock Wonder Blocks Data usage.
@@ -20,9 +22,9 @@ export const defaultConfig = ([]: Array<Interceptor>);
20
22
  * are not overriding one another.
21
23
  */
22
24
  export const adapter: TestHarnessAdapter<Config> = (
23
- children: React.Node,
25
+ children: React.ReactNode,
24
26
  config: Config,
25
- ): React.Element<any> => {
27
+ ): React.ReactElement<any> => {
26
28
  // First we render the cache intercepts.
27
29
  let currentChildren = children;
28
30
 
@@ -1,12 +1,11 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
 
4
- import type {TestHarnessAdapter} from "../types.js";
3
+ import type {TestHarnessAdapter} from "../types";
5
4
 
6
5
  type Config = string;
7
6
 
8
7
  // The default configuration is to omit this adapter.
9
- export const defaultConfig: ?Config = null;
8
+ export const defaultConfig: Config | null | undefined = null;
10
9
 
11
10
  /**
12
11
  * Test harness adapter for supporting portals.
@@ -16,9 +15,9 @@ export const defaultConfig: ?Config = null;
16
15
  * identifier.
17
16
  */
18
17
  export const adapter: TestHarnessAdapter<Config> = (
19
- children: React.Node,
18
+ children: React.ReactNode,
20
19
  config: Config,
21
- ): React.Element<any> => (
20
+ ): React.ReactElement<any> => (
22
21
  <>
23
22
  <div id={config} data-test-id={config} />
24
23
  {children}