@khanacademy/wonder-blocks-testing 8.0.20 → 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.
Files changed (40) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/package.json +3 -3
  3. package/src/harness/adapters/adapters.ts +0 -3
  4. package/src/harness/adapters/router.tsx +0 -2
  5. package/src/harness/types.ts +0 -2
  6. package/src/settle-controller.ts +0 -2
  7. package/src/settle-signal.ts +0 -2
  8. package/tsconfig-build.tsbuildinfo +1 -1
  9. package/dist/fetch/fetch-request-matches-mock.js.flow +0 -16
  10. package/dist/fetch/mock-fetch.js.flow +0 -12
  11. package/dist/fetch/types.js.flow +0 -17
  12. package/dist/fixtures/fixtures.basic.stories.js.flow +0 -21
  13. package/dist/fixtures/fixtures.defaultwrapper.stories.js.flow +0 -17
  14. package/dist/fixtures/fixtures.js.flow +0 -24
  15. package/dist/fixtures/types.js.flow +0 -35
  16. package/dist/gql/gql-request-matches-mock.js.flow +0 -14
  17. package/dist/gql/mock-gql-fetch.js.flow +0 -12
  18. package/dist/gql/types.js.flow +0 -36
  19. package/dist/harness/adapters/adapters.js.flow +0 -28
  20. package/dist/harness/adapters/css.js.flow +0 -21
  21. package/dist/harness/adapters/data.js.flow +0 -29
  22. package/dist/harness/adapters/portal.js.flow +0 -17
  23. package/dist/harness/adapters/router.js.flow +0 -114
  24. package/dist/harness/hook-harness.js.flow +0 -22
  25. package/dist/harness/make-hook-harness.js.flow +0 -27
  26. package/dist/harness/make-test-harness.js.flow +0 -22
  27. package/dist/harness/render-adapters.js.flow +0 -17
  28. package/dist/harness/test-harness.js.flow +0 -74
  29. package/dist/harness/types.js.flow +0 -57
  30. package/dist/index.js.flow +0 -25
  31. package/dist/mock-requester.js.flow +0 -21
  32. package/dist/respond-with.js.flow +0 -88
  33. package/dist/response-impl.js.flow +0 -7
  34. package/dist/settle-controller.js.flow +0 -25
  35. package/dist/settle-signal.js.flow +0 -25
  36. package/dist/types.js.flow +0 -40
  37. package/src/harness/adapters/adapters.js.flow +0 -28
  38. package/src/harness/adapters/router.jsx.flow +0 -112
  39. package/src/harness/make-test-harness.js.flow +0 -22
  40. package/src/harness/types.js.flow +0 -57
@@ -1,35 +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 * as React from "react";
8
-
9
- /**
10
- * Options injected to the function that returns the fixture props.
11
- */
12
- export type GetPropsOptions = {|
13
- /**
14
- * A function to call that will log output.
15
- */
16
- log: (message: string, ...args: Array<any>) => void,
17
-
18
- /**
19
- * A function to make a handler that will log all arguments with the given
20
- * name or message. Useful for logging events as it avoids the boilerplate
21
- * of the `log` function.
22
- */
23
- logHandler: (name: string) => (...args: Array<any>) => void,
24
- |};
25
- export type FixtureProps<TProps: { ... }> =
26
- | $ReadOnly<TProps>
27
- | ((options: $ReadOnly<GetPropsOptions>) => $ReadOnly<TProps>);
28
- /**
29
- * A function for defining a fixture.
30
- */
31
- export type FixtureFn<TProps: { ... }> = (
32
- description: string,
33
- props: FixtureProps<TProps>,
34
- wrapper?: React.ComponentType<TProps>
35
- ) => mixed;
@@ -1,14 +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 { GqlOperation, GqlContext } from "@khanacademy/wonder-blocks-data";
8
- import type { GqlMockOperation } from "./types";
9
- declare export var gqlRequestMatchesMock: (
10
- mock: GqlMockOperation<any, any, any>,
11
- operation: GqlOperation<any, any>,
12
- variables: { [key: any]: any } | null | void,
13
- context: GqlContext
14
- ) => boolean;
@@ -1,12 +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 { GqlFetchMockFn } from "./types";
8
-
9
- /**
10
- * A mock for the fetch function passed to GqlRouter.
11
- */
12
- declare export var mockGqlFetch: () => GqlFetchMockFn;
@@ -1,36 +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 { GqlOperation, GqlContext } from "@khanacademy/wonder-blocks-data";
8
- import type { GraphQLJson } from "../types";
9
- import type { MockResponse } from "../respond-with";
10
- export type GqlMockOperation<
11
- TData: { [key: any]: any },
12
- TVariables: { [key: any]: any },
13
- TContext: GqlContext
14
- > = {|
15
- operation: GqlOperation<TData, TVariables>,
16
- variables?: TVariables,
17
- context?: TContext,
18
- |};
19
- declare type GqlMockOperationFn = <
20
- TData: { [key: any]: any },
21
- TVariables: { [key: any]: any },
22
- TContext: GqlContext,
23
- TResponseData: GraphQLJson<TData>
24
- >(
25
- operation: GqlMockOperation<TData, TVariables, TContext>,
26
- response: MockResponse<TResponseData>
27
- ) => GqlFetchMockFn;
28
- export type GqlFetchMockFn = {|
29
- (
30
- operation: GqlOperation<any, any>,
31
- variables: { [key: any]: any } | null | void,
32
- context: GqlContext
33
- ): Promise<Response>,
34
- mockOperation: GqlMockOperationFn,
35
- mockOperationOnce: GqlMockOperationFn,
36
- |};
@@ -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,21 +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 { CSSProperties } from "aphrodite";
8
- import type { TestHarnessAdapter } from "../types";
9
- declare type Config =
10
- | string
11
- | Array<string>
12
- | CSSProperties
13
- | {|
14
- classes: Array<string>,
15
- style: CSSProperties,
16
- |};
17
- declare export var defaultConfig: Config | null | void;
18
- /**
19
- * Test harness adapter for adding CSS to the harnessed component wrapper.
20
- */
21
- declare export var adapter: TestHarnessAdapter<Config>;
@@ -1,29 +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 * as $Flowgen$Import$_40_khanacademy_2f_wonder_2d_blocks_2d_data from "@khanacademy/wonder-blocks-data";
8
- import * as React from "react";
9
- import { InterceptRequests } from "@khanacademy/wonder-blocks-data";
10
- import type { TestHarnessAdapter } from "../types";
11
- declare type Interceptor = $PropertyType<
12
- React.ElementConfig<typeof InterceptRequests>,
13
- "interceptor"
14
- >;
15
- declare type Config = Interceptor | Array<Interceptor>;
16
- /**
17
- * Default configuration for the Wonder Blocks Data adapter.
18
- */
19
- declare export var defaultConfig: ((
20
- requestId: string
21
- ) => Promise<$Flowgen$Import$_40_khanacademy_2f_wonder_2d_blocks_2d_data.ValidCacheData> | null | void)[];
22
- /**
23
- * Test harness adapter to mock Wonder Blocks Data usage.
24
- *
25
- * NOTE: Consumers are responsible for properly defining their intercepts.
26
- * This component does not validate the configuration to ensure interceptors
27
- * are not overriding one another.
28
- */
29
- declare export var adapter: TestHarnessAdapter<Config>;
@@ -1,17 +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 { TestHarnessAdapter } from "../types";
8
- declare type Config = string;
9
- declare export var defaultConfig: Config | null | void;
10
- /**
11
- * Test harness adapter for supporting portals.
12
- *
13
- * Some components rely on rendering with a React Portal. This adapter ensures
14
- * that the DOM contains a mounting point for the portal with the expected
15
- * identifier.
16
- */
17
- declare export var adapter: TestHarnessAdapter<Config>;
@@ -1,114 +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 * as React from "react";
8
- import { MemoryRouter } from "react-router-dom";
9
- import type { LocationDescriptor } from "history";
10
- import type { TestHarnessAdapter } from "../types";
11
- declare type MemoryRouterProps = React.ElementConfig<typeof MemoryRouter>;
12
- /**
13
- * Configuration for the withLocation test harness adapter.
14
- */
15
- declare type Config =
16
- | $ReadOnly<
17
- | {|
18
- /**
19
- * See MemoryRouter prop for initialEntries.
20
- */
21
- initialEntries: $PropertyType<MemoryRouterProps, "initialEntries">,
22
-
23
- /**
24
- * See MemoryRouter prop for initialIndex.
25
- */
26
- initialIndex?: $PropertyType<MemoryRouterProps, "initialIndex">,
27
-
28
- /**
29
- * See MemoryRouter prop for getUserConfirmation.
30
- */
31
- getUserConfirmation?: $PropertyType<
32
- MemoryRouterProps,
33
- "getUserConfirmation"
34
- >,
35
-
36
- /**
37
- * A path match to use.
38
- *
39
- * When this is specified, the harnessed component will be
40
- * rendered inside a `Route` handler with this path.
41
- *
42
- * If the path matches the location, then the route will
43
- * render the component.
44
- *
45
- * If the path does not match the location, then the route
46
- * will not render the component.
47
- */
48
- path?: string,
49
- |}
50
- | {|
51
- /**
52
- * The location to use.
53
- */
54
- location: LocationDescriptor,
55
-
56
- /**
57
- * Force the use of a StaticRouter, instead of MemoryRouter.
58
- */
59
- forceStatic: true,
60
-
61
- /**
62
- * A path match to use.
63
- *
64
- * When this is specified, the harnessed component will be
65
- * rendered inside a `Route` handler with this path.
66
- *
67
- * If the path matches the location, then the route will
68
- * render the component.
69
- *
70
- * If the path does not match the location, then the route
71
- * will not render the component.
72
- */
73
- path?: string,
74
- |}
75
- | {|
76
- /**
77
- * The initial location to use.
78
- */
79
- location: LocationDescriptor,
80
-
81
- /**
82
- * A path match to use.
83
- *
84
- * When this is specified, the harnessed component will be
85
- * rendered inside a `Route` handler with this path.
86
- *
87
- * If the path matches the location, then the route will
88
- * render the component.
89
- *
90
- * If the path does not match the location, then the route
91
- * will not render the component.
92
- */
93
- path?: string,
94
- |}
95
- >
96
- | string;
97
- /**
98
- * The default configuration for this adapter.
99
- */
100
- declare export var defaultConfig: {|
101
- +location: "/",
102
- |};
103
- /**
104
- * Adapter that sets up a router and AppShell location-specific contexts.
105
- *
106
- * This allows you to ensure that components are being tested in the
107
- * AppShell world.
108
- *
109
- * NOTE(somewhatabstract): The AppShell component itself already does
110
- * the work of setting up routing and the AppShellContext and so using this
111
- * adapter with the App component will have zero-effect since AppShell will
112
- * override it.
113
- */
114
- declare export var adapter: TestHarnessAdapter<Config>;
@@ -1,22 +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 * as React from "react";
8
- import { DefaultAdapters } from "./adapters/adapters";
9
- import type { TestHarnessConfigs } from "./types";
10
-
11
- /**
12
- * Create test wrapper for hook testing with Wonder Blocks default adapters.
13
- *
14
- * This is primarily useful for tests within Wonder Blocks.
15
- *
16
- * If you want to expand the range of adapters or change the default
17
- * configurations, use `makeHookHarness` to create a new `hookHarness`
18
- * function.
19
- */
20
- declare export var hookHarness: (
21
- configs?: $Rest<TestHarnessConfigs<typeof DefaultAdapters>, {}>
22
- ) => React.AbstractComponent<any, any>;
@@ -1,27 +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 * as React from "react";
8
- import type { TestHarnessAdapters, TestHarnessConfigs } from "./types";
9
-
10
- /**
11
- * Create a test harness method for use with React hooks.
12
- *
13
- * This returns a test harness method that applies the default configurations
14
- * to the given adapters, wrapping a given component.
15
- * @param {TAdapters} adapters All the adapters to be supported by the returned
16
- * test harness.
17
- * @param {TestHarnessConfigs<TAdapters>} defaultConfigs Default configuration values for
18
- * the adapters.
19
- * @returns {(
20
- configs?: $Shape<TestHarnessConfigs<TAdapters>>) => React.AbstractComponent<any, any>} A test harness.
21
- */
22
- declare export var makeHookHarness: <TAdapters: TestHarnessAdapters>(
23
- adapters: TAdapters,
24
- defaultConfigs: TestHarnessConfigs<TAdapters>
25
- ) => (
26
- configs?: $Rest<TestHarnessConfigs<TAdapters>, {}> | void
27
- ) => React.AbstractComponent<any, any>;
@@ -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,17 +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 * as React from "react";
8
- import type { TestHarnessConfigs, TestHarnessAdapters } from "./types";
9
-
10
- /**
11
- * Render test adapters around a child component.
12
- */
13
- declare export var renderAdapters: <TAdapters: TestHarnessAdapters>(
14
- adapters: TAdapters,
15
- configs: TestHarnessConfigs<TAdapters>,
16
- children: React.Node
17
- ) => React.Element<any>;
@@ -1,74 +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 * as $Flowgen$Import$react from "react";
8
- import * as $Flowgen$Import$_2e__2f_types from "./types";
9
- import * as $Flowgen$Import$aphrodite from "aphrodite";
10
- import * as $Flowgen$Import$_40_khanacademy_2f_wonder_2d_blocks_2d_data from "@khanacademy/wonder-blocks-data";
11
- import * as $Flowgen$Import$history from "history";
12
-
13
- /**
14
- * Wrap a component with a test harness using Wonder Blocks default adapters.
15
- *
16
- * This is primarily useful for tests within Wonder Blocks.
17
- *
18
- * If you want to expand the range of adapters or change the default
19
- * configurations, use `makeTestHarness` to create a new `testHarness`
20
- * function.
21
- */
22
- declare export var testHarness: <TProps: { ... }>(
23
- Component: $Flowgen$Import$react.ComponentType<TProps>,
24
- configs?: $Rest<
25
- $Flowgen$Import$_2e__2f_types.TestHarnessConfigs<{|
26
- +css: $Flowgen$Import$_2e__2f_types.TestHarnessAdapter<
27
- | string
28
- | string[]
29
- | $Flowgen$Import$aphrodite.CSSProperties
30
- | {|
31
- classes: string[],
32
- style: $Flowgen$Import$aphrodite.CSSProperties,
33
- |}
34
- >,
35
- +data: $Flowgen$Import$_2e__2f_types.TestHarnessAdapter<
36
- | ((
37
- requestId: string
38
- ) => Promise<$Flowgen$Import$_40_khanacademy_2f_wonder_2d_blocks_2d_data.ValidCacheData> | null | void)
39
- | ((
40
- requestId: string
41
- ) => Promise<$Flowgen$Import$_40_khanacademy_2f_wonder_2d_blocks_2d_data.ValidCacheData> | null | void)[]
42
- >,
43
- +portal: $Flowgen$Import$_2e__2f_types.TestHarnessAdapter<string>,
44
- +router: $Flowgen$Import$_2e__2f_types.TestHarnessAdapter<
45
- | string
46
- | $ReadOnly<
47
- | {|
48
- initialEntries:
49
- | $Flowgen$Import$history.LocationDescriptor<mixed>[]
50
- | void,
51
- initialIndex?: number | void,
52
- getUserConfirmation?:
53
- | ((message: string, callback: (ok: boolean) => void) => void)
54
- | void,
55
- path?: string | void,
56
- |}
57
- | {|
58
- location: $Flowgen$Import$history.LocationDescriptor<mixed>,
59
- forceStatic: true,
60
- path?: string | void,
61
- |}
62
- | {|
63
- location: $Flowgen$Import$history.LocationDescriptor<mixed>,
64
- path?: string | void,
65
- |}
66
- >
67
- >,
68
- |}>,
69
- {}
70
- > | void
71
- ) => $Flowgen$Import$react.ForwardRefExoticComponent<{|
72
- ...$Flowgen$Import$react.PropsWithoutRef<TProps>,
73
- ...$Flowgen$Import$react.RefAttributes<mixed>,
74
- |}>;
@@ -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
- >;
@@ -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
- declare export { fixtures } from "./fixtures/fixtures";
8
- export type {
9
- FixtureFn,
10
- FixtureProps,
11
- GetPropsOptions,
12
- } from "./fixtures/types";
13
- declare export { mockFetch } from "./fetch/mock-fetch";
14
- declare export { mockGqlFetch } from "./gql/mock-gql-fetch";
15
- declare export { RespondWith } from "./respond-with";
16
- declare export { SettleController } from "./settle-controller";
17
- export type { MockResponse } from "./respond-with";
18
- export type { FetchMockFn, FetchMockOperation } from "./fetch/types";
19
- export type { GqlFetchMockFn, GqlMockOperation } from "./gql/types";
20
- declare export * from "./harness/types";
21
- declare export * as harnessAdapters from "./harness/adapters/adapters";
22
- declare export { makeHookHarness } from "./harness/make-hook-harness";
23
- declare export { makeTestHarness } from "./harness/make-test-harness";
24
- declare export { hookHarness } from "./harness/hook-harness";
25
- declare export { testHarness } from "./harness/test-harness";
@@ -1,21 +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 { OperationMock, OperationMatcher, MockFn } from "./types";
8
-
9
- /**
10
- * A generic mock request function for using when mocking fetch or gqlFetch.
11
- */
12
- declare export var mockRequester: <
13
- TOperationType,
14
- TOperationMock: OperationMock<TOperationType>
15
- >(
16
- operationMatcher: OperationMatcher<any>,
17
- operationToString: (
18
- operationMock: TOperationMock,
19
- ...args: Array<any>
20
- ) => string
21
- ) => MockFn<TOperationType>;
@@ -1,88 +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
- import type { GraphQLJson } from "./types";
9
-
10
- /**
11
- * Describes a mock response to a fetch request.
12
- */
13
- export type MockResponse<TData> = {|
14
- /**
15
- * Create a promise from the mocked response.
16
- *
17
- * If a signal was provided when the mock response was created, the promise
18
- * will only settle to resolution or rejection if the signal is raised.
19
- */
20
- +toPromise: () => Promise<Response>,
21
- |};
22
- /**
23
- * Helpers to define mock responses for mocked requests.
24
- */
25
- declare export var RespondWith: $ReadOnly<{|
26
- /**
27
- * Response with text body and status code.
28
- * Status code defaults to 200.
29
- */
30
- text: <TData>(
31
- text: string,
32
- statusCode?: number,
33
- signal?: SettleSignal | null
34
- ) => MockResponse<TData>,
35
-
36
- /**
37
- * Response with JSON body and status code 200.
38
- */
39
- json: <TJson: { [key: any]: any }>(
40
- json: TJson,
41
- signal?: SettleSignal | null
42
- ) => MockResponse<TJson>,
43
-
44
- /**
45
- * Response with GraphQL data JSON body and status code 200.
46
- */
47
- graphQLData: <TData_1: { [key: any]: any }>(
48
- data: TData_1,
49
- signal?: SettleSignal | null
50
- ) => MockResponse<GraphQLJson<TData_1>>,
51
-
52
- /**
53
- * Response with body that will not parse as JSON and status code 200.
54
- */
55
- unparseableBody: (signal?: SettleSignal | null) => MockResponse<any>,
56
-
57
- /**
58
- * Rejects with an AbortError to simulate an aborted request.
59
- */
60
- abortedRequest: (signal?: SettleSignal | null) => MockResponse<any>,
61
-
62
- /**
63
- * Rejects with the given error.
64
- */
65
- reject: (error: Error, signal?: SettleSignal | null) => MockResponse<any>,
66
-
67
- /**
68
- * A non-200 status code with empty text body.
69
- * Equivalent to calling `ResponseWith.text("", statusCode)`.
70
- */
71
- errorStatusCode: (
72
- statusCode: number,
73
- signal?: SettleSignal | null
74
- ) => MockResponse<any>,
75
-
76
- /**
77
- * Response body that is valid JSON but not a valid GraphQL response.
78
- */
79
- nonGraphQLBody: (signal?: SettleSignal | null) => MockResponse<any>,
80
-
81
- /**
82
- * Response that is a GraphQL errors response with status code 200.
83
- */
84
- graphQLErrors: (
85
- errorMessages: $ReadOnlyArray<string>,
86
- signal?: SettleSignal | null
87
- ) => MockResponse<GraphQLJson<any>>,
88
- |}>;