@khanacademy/wonder-blocks-testing 2.0.0 → 2.0.1
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 +8 -0
- package/package.json +2 -2
- package/src/gql/gql-request-matches-mock.js +2 -2
- package/src/gql/mock-gql-fetch.js +4 -11
- package/src/gql/types.js +5 -11
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-testing",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime": "^7.16.3",
|
|
17
|
-
"@khanacademy/wonder-blocks-data": "^3.1.
|
|
17
|
+
"@khanacademy/wonder-blocks-data": "^3.1.3"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@khanacademy/wonder-stuff-core": "^0.1.2",
|
|
@@ -36,8 +36,8 @@ const areObjectsEqual = (a: any, b: any): boolean => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export const gqlRequestMatchesMock = (
|
|
39
|
-
mock: GqlMockOperation<any, any, any
|
|
40
|
-
operation: GqlOperation<any, any
|
|
39
|
+
mock: GqlMockOperation<any, any, any>,
|
|
40
|
+
operation: GqlOperation<any, any>,
|
|
41
41
|
variables: ?{...},
|
|
42
42
|
context: GqlContext,
|
|
43
43
|
): boolean => {
|
|
@@ -52,13 +52,8 @@ export const mockGqlFetch = (): GqlFetchMockFn => {
|
|
|
52
52
|
);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
const addMockedOperation = <
|
|
56
|
-
|
|
57
|
-
TData,
|
|
58
|
-
TVariables: {...},
|
|
59
|
-
TContext: GqlContext,
|
|
60
|
-
>(
|
|
61
|
-
operation: GqlMockOperation<TType, TData, TVariables, TContext>,
|
|
55
|
+
const addMockedOperation = <TData, TVariables: {...}, TContext: GqlContext>(
|
|
56
|
+
operation: GqlMockOperation<TData, TVariables, TContext>,
|
|
62
57
|
response: GqlMockResponse<TData>,
|
|
63
58
|
onceOnly: boolean,
|
|
64
59
|
): GqlFetchMockFn => {
|
|
@@ -73,22 +68,20 @@ export const mockGqlFetch = (): GqlFetchMockFn => {
|
|
|
73
68
|
};
|
|
74
69
|
|
|
75
70
|
gqlFetchMock.mockOperation = <
|
|
76
|
-
TType,
|
|
77
71
|
TData,
|
|
78
72
|
TVariables: {...},
|
|
79
73
|
TContext: GqlContext,
|
|
80
74
|
>(
|
|
81
|
-
operation: GqlMockOperation<
|
|
75
|
+
operation: GqlMockOperation<TData, TVariables, TContext>,
|
|
82
76
|
response: GqlMockResponse<TData>,
|
|
83
77
|
): GqlFetchMockFn => addMockedOperation(operation, response, false);
|
|
84
78
|
|
|
85
79
|
gqlFetchMock.mockOperationOnce = <
|
|
86
|
-
TType,
|
|
87
80
|
TData,
|
|
88
81
|
TVariables: {...},
|
|
89
82
|
TContext: GqlContext,
|
|
90
83
|
>(
|
|
91
|
-
operation: GqlMockOperation<
|
|
84
|
+
operation: GqlMockOperation<TData, TVariables, TContext>,
|
|
92
85
|
response: GqlMockResponse<TData>,
|
|
93
86
|
): GqlFetchMockFn => addMockedOperation(operation, response, true);
|
|
94
87
|
|
package/src/gql/types.js
CHANGED
|
@@ -3,29 +3,23 @@ import type {GqlOperation, GqlContext} from "@khanacademy/wonder-blocks-data";
|
|
|
3
3
|
import type {GqlMockResponse} from "./make-gql-mock-response.js";
|
|
4
4
|
|
|
5
5
|
export type GqlMockOperation<
|
|
6
|
-
TType,
|
|
7
6
|
TData,
|
|
8
7
|
TVariables: {...},
|
|
9
8
|
TContext: GqlContext,
|
|
10
9
|
> = {|
|
|
11
|
-
operation: GqlOperation<
|
|
10
|
+
operation: GqlOperation<TData, TVariables>,
|
|
12
11
|
variables?: TVariables,
|
|
13
12
|
context?: TContext,
|
|
14
13
|
|};
|
|
15
14
|
|
|
16
|
-
type GqlMockOperationFn = <
|
|
17
|
-
|
|
18
|
-
TData,
|
|
19
|
-
TVariables: {...},
|
|
20
|
-
TContext: GqlContext,
|
|
21
|
-
>(
|
|
22
|
-
operation: GqlMockOperation<TType, TData, TVariables, TContext>,
|
|
15
|
+
type GqlMockOperationFn = <TData, TVariables: {...}, TContext: GqlContext>(
|
|
16
|
+
operation: GqlMockOperation<TData, TVariables, TContext>,
|
|
23
17
|
response: GqlMockResponse<TData>,
|
|
24
18
|
) => GqlFetchMockFn;
|
|
25
19
|
|
|
26
20
|
export type GqlFetchMockFn = {|
|
|
27
21
|
(
|
|
28
|
-
operation: GqlOperation<any, any
|
|
22
|
+
operation: GqlOperation<any, any>,
|
|
29
23
|
variables: ?{...},
|
|
30
24
|
context: GqlContext,
|
|
31
25
|
): Promise<Response>,
|
|
@@ -34,7 +28,7 @@ export type GqlFetchMockFn = {|
|
|
|
34
28
|
|};
|
|
35
29
|
|
|
36
30
|
export type GqlMock = {|
|
|
37
|
-
operation: GqlMockOperation<any, any, any
|
|
31
|
+
operation: GqlMockOperation<any, any, any>,
|
|
38
32
|
onceOnly: boolean,
|
|
39
33
|
used: boolean,
|
|
40
34
|
response: () => Promise<Response>,
|