@khanacademy/wonder-blocks-testing 8.0.19 → 8.0.21
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 +15 -0
- package/package.json +3 -3
- package/src/harness/adapters/adapters.ts +0 -3
- package/src/harness/adapters/router.tsx +0 -2
- package/src/harness/types.ts +0 -2
- package/src/settle-controller.ts +0 -2
- package/src/settle-signal.ts +0 -2
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/fetch/fetch-request-matches-mock.js.flow +0 -16
- package/dist/fetch/mock-fetch.js.flow +0 -12
- package/dist/fetch/types.js.flow +0 -17
- package/dist/fixtures/fixtures.basic.stories.js.flow +0 -21
- package/dist/fixtures/fixtures.defaultwrapper.stories.js.flow +0 -17
- package/dist/fixtures/fixtures.js.flow +0 -24
- package/dist/fixtures/types.js.flow +0 -35
- package/dist/gql/gql-request-matches-mock.js.flow +0 -14
- package/dist/gql/mock-gql-fetch.js.flow +0 -12
- package/dist/gql/types.js.flow +0 -36
- package/dist/harness/adapters/adapters.js.flow +0 -28
- package/dist/harness/adapters/css.js.flow +0 -21
- package/dist/harness/adapters/data.js.flow +0 -29
- package/dist/harness/adapters/portal.js.flow +0 -17
- package/dist/harness/adapters/router.js.flow +0 -114
- package/dist/harness/hook-harness.js.flow +0 -22
- package/dist/harness/make-hook-harness.js.flow +0 -27
- package/dist/harness/make-test-harness.js.flow +0 -22
- package/dist/harness/render-adapters.js.flow +0 -17
- package/dist/harness/test-harness.js.flow +0 -74
- package/dist/harness/types.js.flow +0 -57
- package/dist/index.js.flow +0 -25
- package/dist/mock-requester.js.flow +0 -21
- package/dist/respond-with.js.flow +0 -88
- package/dist/response-impl.js.flow +0 -7
- package/dist/settle-controller.js.flow +0 -25
- package/dist/settle-signal.js.flow +0 -25
- package/dist/types.js.flow +0 -40
- package/src/harness/adapters/adapters.js.flow +0 -28
- package/src/harness/adapters/router.jsx.flow +0 -112
- package/src/harness/make-test-harness.js.flow +0 -22
- package/src/harness/types.js.flow +0 -57
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import { SettleSignal } from "./settle-signal";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A controller for the `RespondWith` API to control response settlement.
|
|
11
|
-
*/
|
|
12
|
-
declare export class SettleController {
|
|
13
|
-
constructor(): this;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The signal to pass to the `RespondWith` API.
|
|
17
|
-
*/
|
|
18
|
-
signal: SettleSignal;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Settle the signal and therefore any associated responses.
|
|
22
|
-
* @throws {Error} if the signal has already been settled.
|
|
23
|
-
*/
|
|
24
|
-
settle(): void;
|
|
25
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* A signal for controlling the `RespondWith` API responses.
|
|
9
|
-
*
|
|
10
|
-
* This provide finely-grained control over the promise lifecycle to support
|
|
11
|
-
* complex test scenarios.
|
|
12
|
-
*/
|
|
13
|
-
declare export class SettleSignal extends EventTarget {
|
|
14
|
-
constructor(setSettleFn?: ((settleFn: () => void) => mixed) | null): this;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* An already settled signal.
|
|
18
|
-
*/
|
|
19
|
-
static settle(): SettleSignal;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Has this signal been settled yet?
|
|
23
|
-
*/
|
|
24
|
-
settled: boolean;
|
|
25
|
-
}
|
package/dist/types.js.flow
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import type { MockResponse } from "./respond-with";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A valid GraphQL response as supported by our mocking framework.
|
|
11
|
-
* Note that we don't currently support both data and errors being set.
|
|
12
|
-
*/
|
|
13
|
-
export type GraphQLJson<TData: { [key: any]: any }> =
|
|
14
|
-
| {|
|
|
15
|
-
data: TData,
|
|
16
|
-
|}
|
|
17
|
-
| {|
|
|
18
|
-
errors: Array<{|
|
|
19
|
-
message: string,
|
|
20
|
-
|}>,
|
|
21
|
-
|};
|
|
22
|
-
export type MockFn<TOperationType> = {|
|
|
23
|
-
(...args: Array<any>): Promise<Response>,
|
|
24
|
-
mockOperation: MockOperationFn<TOperationType>,
|
|
25
|
-
mockOperationOnce: MockOperationFn<TOperationType>,
|
|
26
|
-
|};
|
|
27
|
-
export type OperationMock<TOperation> = {|
|
|
28
|
-
operation: TOperation,
|
|
29
|
-
onceOnly: boolean,
|
|
30
|
-
used: boolean,
|
|
31
|
-
response: () => Promise<Response>,
|
|
32
|
-
|};
|
|
33
|
-
export type OperationMatcher<TOperation> = (
|
|
34
|
-
operation: TOperation,
|
|
35
|
-
...args: Array<any>
|
|
36
|
-
) => boolean;
|
|
37
|
-
export type MockOperationFn<TOperationType> = <TOperation: TOperationType>(
|
|
38
|
-
operation: TOperation,
|
|
39
|
-
response: MockResponse<any>
|
|
40
|
-
) => MockFn<TOperationType>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @flow
|
|
3
|
-
*/
|
|
4
|
-
import * as css from "./css";
|
|
5
|
-
import * as data from "./data";
|
|
6
|
-
import * as portal from "./portal";
|
|
7
|
-
import * as router from "./router";
|
|
8
|
-
|
|
9
|
-
import type { TestHarnessConfigs, TestHarnessConfig } from "../types";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* NOTE: We do not type `DefaultAdapters` with `Adapters` here because we want
|
|
13
|
-
* the individual config types of each adapter to remain intact rather than
|
|
14
|
-
* getting changed to `any`.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* The default adapters provided by Wonder Blocks.
|
|
18
|
-
*/
|
|
19
|
-
declare export var DefaultAdapters: {|
|
|
20
|
-
+css: typeof css.adapter,
|
|
21
|
-
+data: typeof data.adapter,
|
|
22
|
-
+portal: typeof portal.adapter,
|
|
23
|
-
+router: typeof router.adapter,
|
|
24
|
-
|};
|
|
25
|
-
/**
|
|
26
|
-
* The default configurations to use with the `DefaultAdapters`.
|
|
27
|
-
*/
|
|
28
|
-
declare export var DefaultConfigs: TestHarnessConfigs<typeof DefaultAdapters>;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @flow
|
|
3
|
-
*/
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
import { MemoryRouter } from "react-router-dom";
|
|
6
|
-
import type { LocationShape } from "react-router-dom";
|
|
7
|
-
import type { TestHarnessAdapter } from "../types";
|
|
8
|
-
declare type MemoryRouterProps = React.ElementConfig<typeof MemoryRouter>;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Configuration for the withLocation test harness adapter.
|
|
12
|
-
*/
|
|
13
|
-
declare type Config =
|
|
14
|
-
| $ReadOnly<
|
|
15
|
-
| {|
|
|
16
|
-
/**
|
|
17
|
-
* See MemoryRouter prop for initialEntries.
|
|
18
|
-
*/
|
|
19
|
-
initialEntries: $PropertyType<MemoryRouterProps, "initialEntries">,
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* See MemoryRouter prop for initialIndex.
|
|
23
|
-
*/
|
|
24
|
-
initialIndex?: $PropertyType<MemoryRouterProps, "initialIndex">,
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* See MemoryRouter prop for getUserConfirmation.
|
|
28
|
-
*/
|
|
29
|
-
getUserConfirmation?: $PropertyType<
|
|
30
|
-
MemoryRouterProps,
|
|
31
|
-
"getUserConfirmation"
|
|
32
|
-
>,
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* A path match to use.
|
|
36
|
-
*
|
|
37
|
-
* When this is specified, the harnessed component will be
|
|
38
|
-
* rendered inside a `Route` handler with this path.
|
|
39
|
-
*
|
|
40
|
-
* If the path matches the location, then the route will
|
|
41
|
-
* render the component.
|
|
42
|
-
*
|
|
43
|
-
* If the path does not match the location, then the route
|
|
44
|
-
* will not render the component.
|
|
45
|
-
*/
|
|
46
|
-
path?: string,
|
|
47
|
-
|}
|
|
48
|
-
| {|
|
|
49
|
-
/**
|
|
50
|
-
* The location to use.
|
|
51
|
-
*/
|
|
52
|
-
location: string | LocationShape,
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Force the use of a StaticRouter, instead of MemoryRouter.
|
|
56
|
-
*/
|
|
57
|
-
forceStatic: true,
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* A path match to use.
|
|
61
|
-
*
|
|
62
|
-
* When this is specified, the harnessed component will be
|
|
63
|
-
* rendered inside a `Route` handler with this path.
|
|
64
|
-
*
|
|
65
|
-
* If the path matches the location, then the route will
|
|
66
|
-
* render the component.
|
|
67
|
-
*
|
|
68
|
-
* If the path does not match the location, then the route
|
|
69
|
-
* will not render the component.
|
|
70
|
-
*/
|
|
71
|
-
path?: string,
|
|
72
|
-
|}
|
|
73
|
-
| {|
|
|
74
|
-
/**
|
|
75
|
-
* The initial location to use.
|
|
76
|
-
*/
|
|
77
|
-
location: string | LocationShape,
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* A path match to use.
|
|
81
|
-
*
|
|
82
|
-
* When this is specified, the harnessed component will be
|
|
83
|
-
* rendered inside a `Route` handler with this path.
|
|
84
|
-
*
|
|
85
|
-
* If the path matches the location, then the route will
|
|
86
|
-
* render the component.
|
|
87
|
-
*
|
|
88
|
-
* If the path does not match the location, then the route
|
|
89
|
-
* will not render the component.
|
|
90
|
-
*/
|
|
91
|
-
path?: string,
|
|
92
|
-
|}
|
|
93
|
-
>
|
|
94
|
-
| string;
|
|
95
|
-
/**
|
|
96
|
-
* The default configuration for this adapter.
|
|
97
|
-
*/
|
|
98
|
-
declare export var defaultConfig: {|
|
|
99
|
-
+location: "/",
|
|
100
|
-
|};
|
|
101
|
-
/**
|
|
102
|
-
* Adapter that sets up a router and AppShell location-specific contexts.
|
|
103
|
-
*
|
|
104
|
-
* This allows you to ensure that components are being tested in the
|
|
105
|
-
* AppShell world.
|
|
106
|
-
*
|
|
107
|
-
* NOTE(somewhatabstract): The AppShell component itself already does
|
|
108
|
-
* the work of setting up routing and the AppShellContext and so using this
|
|
109
|
-
* adapter with the App component will have zero-effect since AppShell will
|
|
110
|
-
* override it.
|
|
111
|
-
*/
|
|
112
|
-
declare export var adapter: TestHarnessAdapter<Config>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import type {TestHarnessAdapters, TestHarnessConfigs} from "./types";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Create a test harness method for use with React components.
|
|
7
|
-
*
|
|
8
|
-
* This returns a test harness method that applies the default configurations
|
|
9
|
-
* to the given adapters, wrapping a given component.
|
|
10
|
-
* @param {TAdapters} adapters All the adapters to be supported by the returned
|
|
11
|
-
* test harness.
|
|
12
|
-
* @param {Configs<TAdapters>} defaultConfigs Default configuration values for
|
|
13
|
-
* the adapters.
|
|
14
|
-
* @returns A test harness.
|
|
15
|
-
*/
|
|
16
|
-
declare export var makeTestHarness: <TAdapters: TestHarnessAdapters>(
|
|
17
|
-
adapters: TAdapters,
|
|
18
|
-
defaultConfigs: TestHarnessConfigs<TAdapters>,
|
|
19
|
-
) => <-TProps, +Instance = mixed>(
|
|
20
|
-
Component: React.AbstractComponent<TProps, Instance>,
|
|
21
|
-
configs?: $Shape<TestHarnessConfigs<TAdapters>>,
|
|
22
|
-
) => React.AbstractComponent<TProps, Instance>;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A adapter to be composed with our test harnass infrastructure.
|
|
6
|
-
*/
|
|
7
|
-
export type TestHarnessAdapter<TConfig> = (
|
|
8
|
-
children: React.Node,
|
|
9
|
-
config: TConfig,
|
|
10
|
-
) => React.Element<any>;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A general map of adapters by their identifiers.
|
|
14
|
-
*
|
|
15
|
-
* It's OK that this has `any` for the config type as this is the very base
|
|
16
|
-
* version of a adapter set. In reality, a more specific type will be used
|
|
17
|
-
* with the harness functions that use more specific definitions of known
|
|
18
|
-
* adapters. This is just to support the base reality of not knowing.
|
|
19
|
-
*
|
|
20
|
-
* Use this on input positions only. Output positions for adapters
|
|
21
|
-
* should infer their type in most cases to ensure the strongest typing of
|
|
22
|
-
* the adapters.
|
|
23
|
-
*/
|
|
24
|
-
export type TestHarnessAdapters = {|
|
|
25
|
-
+[adapterID: string]: TestHarnessAdapter<any>,
|
|
26
|
-
|};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Mapping functions from a adapter-like function to config type.
|
|
30
|
-
*/
|
|
31
|
-
type ExtractConfig = <TConfig>(TestHarnessAdapter<TConfig>) => TConfig;
|
|
32
|
-
type ExtractMaybeConfig = <TConfig>(TestHarnessAdapter<TConfig>) => ?TConfig;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Type for easily defining an adapter's config type.
|
|
36
|
-
*
|
|
37
|
-
* This is the `TestHarnessAdapter` equivalent of `React.ElementConfig`.
|
|
38
|
-
*/
|
|
39
|
-
export type TestHarnessConfig<TAdapter> = $Call<ExtractConfig, TAdapter>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The `TestHarnessConfigs` type as defined by parsing a given set of adapters.
|
|
43
|
-
*
|
|
44
|
-
* NOTE: This only works if the properties of the passed `TAdapters` type
|
|
45
|
-
* are explicitly typed as `TestHarnessAdapter<TConfig>` so if passing in a
|
|
46
|
-
* non-Adapters type (which we should be, to get strong `TConfig` types instead
|
|
47
|
-
* of `any`), then that object should make sure that each adapter is strongly
|
|
48
|
-
* marked as `TestHarnessAdapter<TConfig>` - flow does not appear to pattern
|
|
49
|
-
* match against the type definition when invoking the `ExtractConfig` type and I
|
|
50
|
-
* haven't worked out how to get it to multi-dispatch so that it matches
|
|
51
|
-
* functions too. Even worse, if the type doesn't match, it just allows `any`
|
|
52
|
-
* in the `Configs` object, rather than indicating any kind of problem.
|
|
53
|
-
*/
|
|
54
|
-
export type TestHarnessConfigs<TAdapters: TestHarnessAdapters> = $ObjMap<
|
|
55
|
-
TAdapters,
|
|
56
|
-
ExtractMaybeConfig,
|
|
57
|
-
>;
|