@khanacademy/wonder-blocks-testing 15.1.5 → 15.1.6
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 +9 -0
- package/dist/es/index.js +9 -77
- package/dist/index.js +9 -100
- package/package.json +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-testing
|
|
2
2
|
|
|
3
|
+
## 15.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [28fa0c0]
|
|
8
|
+
- Updated dependencies [28fa0c0]
|
|
9
|
+
- @khanacademy/wonder-blocks-core@12.3.0
|
|
10
|
+
- @khanacademy/wonder-blocks-data@14.1.4
|
|
11
|
+
|
|
3
12
|
## 15.1.5
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/es/index.js
CHANGED
|
@@ -1,90 +1,22 @@
|
|
|
1
1
|
import { mockRequester, harnessAdapters } from '@khanacademy/wonder-blocks-testing-core';
|
|
2
2
|
export { RespondWith, SettleController, fixtures, hookHarness, makeHookHarness, makeTestHarness, mockFetch, renderHookStatic, testHarness } from '@khanacademy/wonder-blocks-testing-core';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
5
|
import { InterceptRequests } from '@khanacademy/wonder-blocks-data';
|
|
6
6
|
import { KindError, Errors } from '@khanacademy/wonder-stuff-core';
|
|
7
7
|
import { RenderStateRoot } from '@khanacademy/wonder-blocks-core';
|
|
8
8
|
|
|
9
|
-
const areObjectsEquivalent = (a,
|
|
10
|
-
if (a === b) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
if (a == null || b == null) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
if (typeof a !== "object" || typeof b !== "object") {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
const aKeys = Object.keys(a);
|
|
20
|
-
const bKeys = Object.keys(b);
|
|
21
|
-
const allKeys = new Set([...aKeys, ...bKeys]);
|
|
22
|
-
for (const key of allKeys) {
|
|
23
|
-
if (!areObjectsEquivalent(a[key], b[key])) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
};
|
|
29
|
-
const gqlRequestMatchesMock = (mock, operation, variables, context) => {
|
|
30
|
-
if (mock.operation.id !== operation.id || mock.operation.type !== operation.type) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
if (mock.variables != null) {
|
|
34
|
-
if (!areObjectsEquivalent(mock.variables, variables)) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (mock.context != null) {
|
|
39
|
-
if (!areObjectsEquivalent(mock.context, context)) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return true;
|
|
44
|
-
};
|
|
9
|
+
const areObjectsEquivalent=(a,b)=>{if(a===b){return true}if(a==null||b==null){return false}if(typeof a!=="object"||typeof b!=="object"){return false}const aKeys=Object.keys(a);const bKeys=Object.keys(b);const allKeys=new Set([...aKeys,...bKeys]);for(const key of allKeys){if(!areObjectsEquivalent(a[key],b[key])){return false}}return true};const gqlRequestMatchesMock=(mock,operation,variables,context)=>{if(mock.operation.id!==operation.id||mock.operation.type!==operation.type){return false}if(mock.variables!=null){if(!areObjectsEquivalent(mock.variables,variables)){return false}}if(mock.context!=null){if(!areObjectsEquivalent(mock.context,context)){return false}}return true};
|
|
45
10
|
|
|
46
|
-
const mockGqlFetch
|
|
47
|
-
Variables: ${variables
|
|
48
|
-
Context: ${JSON.stringify(context,
|
|
11
|
+
const mockGqlFetch=()=>mockRequester(gqlRequestMatchesMock,(operation,variables,context)=>`Operation: ${operation.type} ${operation.id}
|
|
12
|
+
Variables: ${variables==null?"None":JSON.stringify(variables,null,2)}
|
|
13
|
+
Context: ${JSON.stringify(context,null,2)}`);
|
|
49
14
|
|
|
50
|
-
const defaultConfig$1 = [];
|
|
51
|
-
const adapter$1 = (children, config) => {
|
|
52
|
-
let currentChildren = children;
|
|
53
|
-
const interceptors = Array.isArray(config) ? config : [config];
|
|
54
|
-
for (const interceptor of interceptors) {
|
|
55
|
-
currentChildren = React.createElement(InterceptRequests, {
|
|
56
|
-
interceptor: interceptor
|
|
57
|
-
}, currentChildren);
|
|
58
|
-
}
|
|
59
|
-
return React.createElement(React.Fragment, null, currentChildren);
|
|
60
|
-
};
|
|
15
|
+
const defaultConfig$1=[];const adapter$1=(children,config)=>{let currentChildren=children;const interceptors=Array.isArray(config)?config:[config];for(const interceptor of interceptors){currentChildren=jsx(InterceptRequests,{interceptor:interceptor,children:currentChildren});}return jsx(Fragment,{children:currentChildren})};
|
|
61
16
|
|
|
62
|
-
const defaultConfig = null;
|
|
63
|
-
const adapter = (children, config) => {
|
|
64
|
-
if (config !== true) {
|
|
65
|
-
throw new KindError("Unexpected configuration: set config to null to turn this adapter off", Errors.InvalidInput, {
|
|
66
|
-
metadata: {
|
|
67
|
-
config
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return React.createElement(RenderStateRoot, {
|
|
72
|
-
throwIfNested: false
|
|
73
|
-
}, children);
|
|
74
|
-
};
|
|
17
|
+
const defaultConfig=null;const adapter=(children,config)=>{if(config!==true){throw new KindError("Unexpected configuration: set config to null to turn this adapter off",Errors.InvalidInput,{metadata:{config}})}return jsx(RenderStateRoot,{throwIfNested:false,children:children})};
|
|
75
18
|
|
|
76
|
-
const DefaultAdapters =
|
|
77
|
-
boundary: harnessAdapters.DefaultAdapters.boundary,
|
|
78
|
-
css: harnessAdapters.DefaultAdapters.css,
|
|
79
|
-
data: adapter$1,
|
|
80
|
-
portal: harnessAdapters.DefaultAdapters.portal,
|
|
81
|
-
router: harnessAdapters.DefaultAdapters.router,
|
|
82
|
-
renderState: adapter
|
|
83
|
-
};
|
|
84
|
-
const DefaultConfigs = _extends({}, harnessAdapters.DefaultConfigs, {
|
|
85
|
-
data: defaultConfig$1,
|
|
86
|
-
renderState: defaultConfig
|
|
87
|
-
});
|
|
19
|
+
const DefaultAdapters={boundary:harnessAdapters.DefaultAdapters.boundary,css:harnessAdapters.DefaultAdapters.css,data:adapter$1,portal:harnessAdapters.DefaultAdapters.portal,router:harnessAdapters.DefaultAdapters.router,renderState:adapter};const DefaultConfigs={...harnessAdapters.DefaultConfigs,data:defaultConfig$1,renderState:defaultConfig};
|
|
88
20
|
|
|
89
21
|
var index = /*#__PURE__*/Object.freeze({
|
|
90
22
|
__proto__: null,
|
package/dist/index.js
CHANGED
|
@@ -3,114 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var wonderBlocksTestingCore = require('@khanacademy/wonder-blocks-testing-core');
|
|
6
|
-
var
|
|
7
|
-
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
require('react');
|
|
8
8
|
var wonderBlocksData = require('@khanacademy/wonder-blocks-data');
|
|
9
9
|
var wonderStuffCore = require('@khanacademy/wonder-stuff-core');
|
|
10
10
|
var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const areObjectsEquivalent=(a,b)=>{if(a===b){return true}if(a==null||b==null){return false}if(typeof a!=="object"||typeof b!=="object"){return false}const aKeys=Object.keys(a);const bKeys=Object.keys(b);const allKeys=new Set([...aKeys,...bKeys]);for(const key of allKeys){if(!areObjectsEquivalent(a[key],b[key])){return false}}return true};const gqlRequestMatchesMock=(mock,operation,variables,context)=>{if(mock.operation.id!==operation.id||mock.operation.type!==operation.type){return false}if(mock.variables!=null){if(!areObjectsEquivalent(mock.variables,variables)){return false}}if(mock.context!=null){if(!areObjectsEquivalent(mock.context,context)){return false}}return true};
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (e) {
|
|
18
|
-
Object.keys(e).forEach(function (k) {
|
|
19
|
-
if (k !== 'default') {
|
|
20
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return e[k]; }
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
n["default"] = e;
|
|
29
|
-
return Object.freeze(n);
|
|
30
|
-
}
|
|
14
|
+
const mockGqlFetch=()=>wonderBlocksTestingCore.mockRequester(gqlRequestMatchesMock,(operation,variables,context)=>`Operation: ${operation.type} ${operation.id}
|
|
15
|
+
Variables: ${variables==null?"None":JSON.stringify(variables,null,2)}
|
|
16
|
+
Context: ${JSON.stringify(context,null,2)}`);
|
|
31
17
|
|
|
32
|
-
|
|
33
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
18
|
+
const defaultConfig$1=[];const adapter$1=(children,config)=>{let currentChildren=children;const interceptors=Array.isArray(config)?config:[config];for(const interceptor of interceptors){currentChildren=jsxRuntime.jsx(wonderBlocksData.InterceptRequests,{interceptor:interceptor,children:currentChildren});}return jsxRuntime.jsx(jsxRuntime.Fragment,{children:currentChildren})};
|
|
34
19
|
|
|
35
|
-
const
|
|
36
|
-
if (a === b) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
if (a == null || b == null) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
if (typeof a !== "object" || typeof b !== "object") {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
const aKeys = Object.keys(a);
|
|
46
|
-
const bKeys = Object.keys(b);
|
|
47
|
-
const allKeys = new Set([...aKeys, ...bKeys]);
|
|
48
|
-
for (const key of allKeys) {
|
|
49
|
-
if (!areObjectsEquivalent(a[key], b[key])) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
};
|
|
55
|
-
const gqlRequestMatchesMock = (mock, operation, variables, context) => {
|
|
56
|
-
if (mock.operation.id !== operation.id || mock.operation.type !== operation.type) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
if (mock.variables != null) {
|
|
60
|
-
if (!areObjectsEquivalent(mock.variables, variables)) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (mock.context != null) {
|
|
65
|
-
if (!areObjectsEquivalent(mock.context, context)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
70
|
-
};
|
|
20
|
+
const defaultConfig=null;const adapter=(children,config)=>{if(config!==true){throw new wonderStuffCore.KindError("Unexpected configuration: set config to null to turn this adapter off",wonderStuffCore.Errors.InvalidInput,{metadata:{config}})}return jsxRuntime.jsx(wonderBlocksCore.RenderStateRoot,{throwIfNested:false,children:children})};
|
|
71
21
|
|
|
72
|
-
const
|
|
73
|
-
Variables: ${variables == null ? "None" : JSON.stringify(variables, null, 2)}
|
|
74
|
-
Context: ${JSON.stringify(context, null, 2)}`);
|
|
75
|
-
|
|
76
|
-
const defaultConfig$1 = [];
|
|
77
|
-
const adapter$1 = (children, config) => {
|
|
78
|
-
let currentChildren = children;
|
|
79
|
-
const interceptors = Array.isArray(config) ? config : [config];
|
|
80
|
-
for (const interceptor of interceptors) {
|
|
81
|
-
currentChildren = React__namespace.createElement(wonderBlocksData.InterceptRequests, {
|
|
82
|
-
interceptor: interceptor
|
|
83
|
-
}, currentChildren);
|
|
84
|
-
}
|
|
85
|
-
return React__namespace.createElement(React__namespace.Fragment, null, currentChildren);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const defaultConfig = null;
|
|
89
|
-
const adapter = (children, config) => {
|
|
90
|
-
if (config !== true) {
|
|
91
|
-
throw new wonderStuffCore.KindError("Unexpected configuration: set config to null to turn this adapter off", wonderStuffCore.Errors.InvalidInput, {
|
|
92
|
-
metadata: {
|
|
93
|
-
config
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
return React__namespace.createElement(wonderBlocksCore.RenderStateRoot, {
|
|
98
|
-
throwIfNested: false
|
|
99
|
-
}, children);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const DefaultAdapters = {
|
|
103
|
-
boundary: wonderBlocksTestingCore.harnessAdapters.DefaultAdapters.boundary,
|
|
104
|
-
css: wonderBlocksTestingCore.harnessAdapters.DefaultAdapters.css,
|
|
105
|
-
data: adapter$1,
|
|
106
|
-
portal: wonderBlocksTestingCore.harnessAdapters.DefaultAdapters.portal,
|
|
107
|
-
router: wonderBlocksTestingCore.harnessAdapters.DefaultAdapters.router,
|
|
108
|
-
renderState: adapter
|
|
109
|
-
};
|
|
110
|
-
const DefaultConfigs = _extends__default["default"]({}, wonderBlocksTestingCore.harnessAdapters.DefaultConfigs, {
|
|
111
|
-
data: defaultConfig$1,
|
|
112
|
-
renderState: defaultConfig
|
|
113
|
-
});
|
|
22
|
+
const DefaultAdapters={boundary:wonderBlocksTestingCore.harnessAdapters.DefaultAdapters.boundary,css:wonderBlocksTestingCore.harnessAdapters.DefaultAdapters.css,data:adapter$1,portal:wonderBlocksTestingCore.harnessAdapters.DefaultAdapters.portal,router:wonderBlocksTestingCore.harnessAdapters.DefaultAdapters.router,renderState:adapter};const DefaultConfigs={...wonderBlocksTestingCore.harnessAdapters.DefaultConfigs,data:defaultConfig$1,renderState:defaultConfig};
|
|
114
23
|
|
|
115
24
|
var index = /*#__PURE__*/Object.freeze({
|
|
116
25
|
__proto__: null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-testing",
|
|
3
|
-
"version": "15.1.
|
|
3
|
+
"version": "15.1.6",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
"module": "dist/es/index.js",
|
|
11
11
|
"types": "dist/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@
|
|
14
|
-
"@khanacademy/wonder-blocks-
|
|
15
|
-
"@khanacademy/wonder-blocks-data": "14.1.3",
|
|
13
|
+
"@khanacademy/wonder-blocks-core": "12.3.0",
|
|
14
|
+
"@khanacademy/wonder-blocks-data": "14.1.4",
|
|
16
15
|
"@khanacademy/wonder-blocks-testing-core": "3.0.1"
|
|
17
16
|
},
|
|
18
17
|
"peerDependencies": {
|
|
@@ -27,7 +26,7 @@
|
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
29
28
|
"@khanacademy/wonder-stuff-testing": "^3.0.5",
|
|
30
|
-
"@khanacademy/wb-dev-build-settings": "
|
|
29
|
+
"@khanacademy/wb-dev-build-settings": "3.0.0"
|
|
31
30
|
},
|
|
32
31
|
"author": "",
|
|
33
32
|
"license": "MIT",
|