@khanacademy/wonder-blocks-testing 4.0.4 → 5.0.2
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 +21 -0
- package/dist/es/index.js +212 -26
- package/dist/index.js +589 -62
- package/package.json +5 -3
- package/src/__docs__/_overview_.stories.mdx +3 -4
- package/src/__docs__/_overview_fixtures.stories.mdx +22 -0
- package/src/__docs__/_overview_mocking.stories.mdx +14 -0
- package/src/__docs__/_overview_test_harness.stories.mdx +18 -0
- package/src/__docs__/exports.fixture-adapters.stories.mdx +49 -0
- package/src/__docs__/exports.fixtures.stories.mdx +53 -0
- package/src/__docs__/exports.harness-adapters.stories.mdx +187 -0
- package/src/__docs__/exports.hook-harness.stories.mdx +22 -0
- package/src/__docs__/exports.make-hook-harness.stories.mdx +25 -0
- package/src/__docs__/exports.make-test-harness.stories.mdx +28 -0
- package/src/__docs__/exports.mock-fetch.stories.mdx +40 -0
- package/src/__docs__/exports.mock-gql-fetch.stories.mdx +13 -8
- package/src/__docs__/exports.respond-with.stories.mdx +54 -8
- package/src/__docs__/exports.setup-fixtures.stories.mdx +22 -0
- package/src/__docs__/exports.test-harness.stories.mdx +23 -0
- package/src/__docs__/types.custom-mount-props.stories.mdx +35 -0
- package/src/__docs__/types.fetch-mock-fn.stories.mdx +22 -0
- package/src/__docs__/types.fetch-mock-operation.stories.mdx +18 -0
- package/src/__docs__/types.fixtures-adapter-factory.stories.mdx +23 -0
- package/src/__docs__/types.fixtures-adapter-fixture-options.stories.mdx +35 -0
- package/src/__docs__/types.fixtures-adapter-group-options.stories.mdx +37 -0
- package/src/__docs__/types.fixtures-adapter-group.stories.mdx +43 -0
- package/src/__docs__/types.fixtures-adapter-options.stories.mdx +21 -0
- package/src/__docs__/types.fixtures-adapter.stories.mdx +35 -0
- package/src/__docs__/types.fixtures-configuration.stories.mdx +35 -0
- package/src/__docs__/types.fixtures-options.stories.mdx +51 -0
- package/src/__docs__/types.get-props-options.stories.mdx +25 -0
- package/src/__docs__/types.gql-fetch-mock-fn.stories.mdx +27 -0
- package/src/__docs__/types.gql-mock-operation.stories.mdx +26 -0
- package/src/__docs__/types.mock-response.stories.mdx +18 -0
- package/src/__docs__/types.test-harness-adapter.stories.mdx +21 -0
- package/src/__docs__/types.test-harness-adapters.stories.mdx +46 -0
- package/src/__docs__/types.test-harness-config.stories.mdx +18 -0
- package/src/__docs__/types.test-harness-configs.stories.mdx +59 -0
- package/src/fetch/types.js +0 -3
- package/src/fixtures/adapters/adapter-group.js +11 -11
- package/src/fixtures/adapters/adapter.js +8 -8
- package/src/fixtures/adapters/storybook.js +11 -8
- package/src/fixtures/fixtures.basic.stories.js +6 -2
- package/src/fixtures/fixtures.defaultwrapper.stories.js +6 -2
- package/src/fixtures/setup.js +8 -4
- package/src/fixtures/types.js +27 -16
- package/src/gql/types.js +1 -3
- package/src/harness/__tests__/hook-harness.test.js +72 -0
- package/src/harness/__tests__/make-hook-harness.test.js +94 -0
- package/src/harness/__tests__/make-test-harness.test.js +190 -0
- package/src/harness/__tests__/render-adapters.test.js +88 -0
- package/src/harness/__tests__/test-harness.test.js +74 -0
- package/src/harness/__tests__/types.flowtest.js +115 -0
- package/src/harness/adapters/__tests__/__snapshots__/router.test.js.snap +5 -0
- package/src/harness/adapters/__tests__/css.test.js +96 -0
- package/src/harness/adapters/__tests__/data.test.js +66 -0
- package/src/harness/adapters/__tests__/portal.test.js +31 -0
- package/src/harness/adapters/__tests__/router.test.js +233 -0
- package/src/harness/adapters/adapters.js +33 -0
- package/src/harness/adapters/css.js +65 -0
- package/src/harness/adapters/data.js +46 -0
- package/src/harness/adapters/portal.js +26 -0
- package/src/harness/adapters/router.js +206 -0
- package/src/harness/hook-harness.js +23 -0
- package/src/harness/make-hook-harness.js +39 -0
- package/src/harness/make-test-harness.js +68 -0
- package/src/harness/render-adapters.js +27 -0
- package/src/harness/test-harness.js +24 -0
- package/src/harness/types.js +57 -0
- package/src/index.js +22 -18
package/dist/index.js
CHANGED
|
@@ -82,11 +82,124 @@ module.exports =
|
|
|
82
82
|
/******/
|
|
83
83
|
/******/
|
|
84
84
|
/******/ // Load entry module and return exports
|
|
85
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 31);
|
|
86
86
|
/******/ })
|
|
87
87
|
/************************************************************************/
|
|
88
88
|
/******/ ([
|
|
89
89
|
/* 0 */
|
|
90
|
+
/***/ (function(module, exports) {
|
|
91
|
+
|
|
92
|
+
module.exports = require("react");
|
|
93
|
+
|
|
94
|
+
/***/ }),
|
|
95
|
+
/* 1 */
|
|
96
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
97
|
+
|
|
98
|
+
"use strict";
|
|
99
|
+
__webpack_require__.r(__webpack_exports__);
|
|
100
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultAdapters", function() { return DefaultAdapters; });
|
|
101
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultConfigs", function() { return DefaultConfigs; });
|
|
102
|
+
/* harmony import */ var _css_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
|
|
103
|
+
/* harmony import */ var _data_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
|
|
104
|
+
/* harmony import */ var _portal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10);
|
|
105
|
+
/* harmony import */ var _router_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(11);
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* NOTE: We do not type `DefaultAdapters` with `Adapters` here because we want
|
|
113
|
+
* the individual config types of each adapter to remain intact rather than
|
|
114
|
+
* getting changed to `any`.
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The default adapters provided by Wonder Blocks.
|
|
119
|
+
*/
|
|
120
|
+
const DefaultAdapters = {
|
|
121
|
+
css: _css_js__WEBPACK_IMPORTED_MODULE_0__[/* adapter */ "a"],
|
|
122
|
+
data: _data_js__WEBPACK_IMPORTED_MODULE_1__[/* adapter */ "a"],
|
|
123
|
+
portal: _portal_js__WEBPACK_IMPORTED_MODULE_2__[/* adapter */ "a"],
|
|
124
|
+
router: _router_js__WEBPACK_IMPORTED_MODULE_3__[/* adapter */ "a"]
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* The default configurations to use with the `DefaultAdapters`.
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
const DefaultConfigs = {
|
|
131
|
+
css: _css_js__WEBPACK_IMPORTED_MODULE_0__[/* defaultConfig */ "b"],
|
|
132
|
+
data: _data_js__WEBPACK_IMPORTED_MODULE_1__[/* defaultConfig */ "b"],
|
|
133
|
+
portal: _portal_js__WEBPACK_IMPORTED_MODULE_2__[/* defaultConfig */ "b"],
|
|
134
|
+
router: _router_js__WEBPACK_IMPORTED_MODULE_3__[/* defaultConfig */ "b"]
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/***/ }),
|
|
138
|
+
/* 2 */
|
|
139
|
+
/***/ (function(module, exports) {
|
|
140
|
+
|
|
141
|
+
module.exports = require("react-router-dom");
|
|
142
|
+
|
|
143
|
+
/***/ }),
|
|
144
|
+
/* 3 */
|
|
145
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
146
|
+
|
|
147
|
+
"use strict";
|
|
148
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return makeTestHarness; });
|
|
149
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
150
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
151
|
+
/* harmony import */ var _render_adapters_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(30);
|
|
152
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Create a test harness method for use with React components.
|
|
159
|
+
*
|
|
160
|
+
* This returns a test harness method that applies the default configurations
|
|
161
|
+
* to the given adapters, wrapping a given component.
|
|
162
|
+
*
|
|
163
|
+
* @param {TAdapters} adapters All the adapters to be supported by the returned
|
|
164
|
+
* test harness.
|
|
165
|
+
* @param {Configs<TAdapters>} defaultConfigs Default configuration values for
|
|
166
|
+
* the adapters.
|
|
167
|
+
* @returns {<-TProps, +Instance = mixed>(
|
|
168
|
+
* Component: React.AbstractComponent<TProps, Instance>,
|
|
169
|
+
* configs?: $Shape<Configs<TAdapters>>,
|
|
170
|
+
* ) => React.AbstractComponent<TProps, Instance>} A test harness.
|
|
171
|
+
*/
|
|
172
|
+
const makeTestHarness = (adapters, defaultConfigs) => {
|
|
173
|
+
/**
|
|
174
|
+
* Create a harnessed version of the given component.
|
|
175
|
+
*
|
|
176
|
+
* @param {React.AbstractComponent<TProps, Instance>} component The
|
|
177
|
+
* component to be wrapped.
|
|
178
|
+
* @param {$Shape<Configs<TAdapters>>} [configs] Any adapter
|
|
179
|
+
* configuration that you want to override from the `defaultConfigs` values.
|
|
180
|
+
*/
|
|
181
|
+
return (Component, configs) => {
|
|
182
|
+
/**
|
|
183
|
+
* $FlowIgnore[cannot-spread-indexer]
|
|
184
|
+
* We know `configs` may overwrite `DefaultConfigs` and we're ok with it.
|
|
185
|
+
* The interface definition handles the typing for us so we're ok
|
|
186
|
+
* with it not being inferred here.
|
|
187
|
+
*/
|
|
188
|
+
const fullConfig = { ...defaultConfigs,
|
|
189
|
+
...configs
|
|
190
|
+
};
|
|
191
|
+
const harnessedComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["forwardRef"]((props, ref) => Object(_render_adapters_js__WEBPACK_IMPORTED_MODULE_1__[/* renderAdapters */ "a"])(adapters, fullConfig, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](Component, _extends({}, props, {
|
|
192
|
+
ref: ref
|
|
193
|
+
})))); // We add a name for the component here so that we can detect that
|
|
194
|
+
// later and also see it in traces and what have you.
|
|
195
|
+
|
|
196
|
+
harnessedComponent.displayName = `testHarness(${Component.displayName || Component.name || "Component"})`;
|
|
197
|
+
return harnessedComponent;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/***/ }),
|
|
202
|
+
/* 4 */
|
|
90
203
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
91
204
|
|
|
92
205
|
"use strict";
|
|
@@ -116,13 +229,13 @@ const getConfiguration = () => {
|
|
|
116
229
|
};
|
|
117
230
|
|
|
118
231
|
/***/ }),
|
|
119
|
-
/*
|
|
232
|
+
/* 5 */
|
|
120
233
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
121
234
|
|
|
122
235
|
"use strict";
|
|
123
236
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return RespondWith; });
|
|
124
237
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return makeMockResponse; });
|
|
125
|
-
/* harmony import */ var _response_impl_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
238
|
+
/* harmony import */ var _response_impl_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(27);
|
|
126
239
|
|
|
127
240
|
|
|
128
241
|
/**
|
|
@@ -236,18 +349,55 @@ const makeMockResponse = response => {
|
|
|
236
349
|
};
|
|
237
350
|
|
|
238
351
|
/***/ }),
|
|
239
|
-
/*
|
|
240
|
-
/***/ (function(module,
|
|
352
|
+
/* 6 */
|
|
353
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
241
354
|
|
|
242
|
-
|
|
355
|
+
"use strict";
|
|
356
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return makeHookHarness; });
|
|
357
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
358
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
359
|
+
/* harmony import */ var _make_test_harness_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
const HookHarness = ({
|
|
364
|
+
children
|
|
365
|
+
}) => children;
|
|
366
|
+
/**
|
|
367
|
+
* Create a test harness method for use with React hooks.
|
|
368
|
+
*
|
|
369
|
+
* This returns a test harness method that applies the default configurations
|
|
370
|
+
* to the given adapters, wrapping a given component.
|
|
371
|
+
*
|
|
372
|
+
* @param {TAdapters} adapters All the adapters to be supported by the returned
|
|
373
|
+
* test harness.
|
|
374
|
+
* @param {TestHarnessConfigs<TAdapters>} defaultConfigs Default configuration values for
|
|
375
|
+
* the adapters.
|
|
376
|
+
* @returns {(
|
|
377
|
+
* configs?: $Shape<TestHarnessConfigs<TAdapters>>,
|
|
378
|
+
* ) => React.AbstractComponent<any, any>} A test harness.
|
|
379
|
+
*/
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
const makeHookHarness = (adapters, defaultConfigs) => {
|
|
383
|
+
const testHarness = Object(_make_test_harness_js__WEBPACK_IMPORTED_MODULE_1__[/* makeTestHarness */ "a"])(adapters, defaultConfigs);
|
|
384
|
+
/**
|
|
385
|
+
* Create a harness to use as a wrapper when rendering hooks.
|
|
386
|
+
*
|
|
387
|
+
* @param {$Shape<Configs<typeof DefaultAdapters>>} [configs] Any adapter
|
|
388
|
+
* configuration that you want to override from the DefaultConfigs values.
|
|
389
|
+
*/
|
|
390
|
+
|
|
391
|
+
return configs => testHarness(HookHarness, configs);
|
|
392
|
+
};
|
|
243
393
|
|
|
244
394
|
/***/ }),
|
|
245
|
-
/*
|
|
395
|
+
/* 7 */
|
|
246
396
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
247
397
|
|
|
248
398
|
"use strict";
|
|
249
399
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return mockRequester; });
|
|
250
|
-
/* harmony import */ var _make_mock_response_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
400
|
+
/* harmony import */ var _make_mock_response_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
|
|
251
401
|
|
|
252
402
|
|
|
253
403
|
/**
|
|
@@ -300,27 +450,280 @@ const mockRequester = (operationMatcher, operationToString) => {
|
|
|
300
450
|
};
|
|
301
451
|
|
|
302
452
|
/***/ }),
|
|
303
|
-
/*
|
|
453
|
+
/* 8 */
|
|
454
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
455
|
+
|
|
456
|
+
"use strict";
|
|
457
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return defaultConfig; });
|
|
458
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return adapter; });
|
|
459
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
460
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
461
|
+
|
|
462
|
+
// The default configuration is to omit this adapter.
|
|
463
|
+
const defaultConfig = null;
|
|
464
|
+
|
|
465
|
+
const normalizeConfig = config => {
|
|
466
|
+
if (typeof config === "string") {
|
|
467
|
+
return {
|
|
468
|
+
classes: [config],
|
|
469
|
+
style: {}
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if (Array.isArray(config)) {
|
|
474
|
+
return {
|
|
475
|
+
classes: config,
|
|
476
|
+
style: {}
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (typeof config === "object") {
|
|
481
|
+
if (config.classes != null && config.style != null) {
|
|
482
|
+
// This is a heuristic check and by nature isn't perfect.
|
|
483
|
+
// So we have to tell flow to just accept it.
|
|
484
|
+
// $FlowIgnore[prop-missing]
|
|
485
|
+
return config;
|
|
486
|
+
} // Again, since the previous check is heuristic, so is this outcome
|
|
487
|
+
// and so we still have to assure flow everything is OK.
|
|
488
|
+
// $FlowIgnore[prop-missing]
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
return {
|
|
492
|
+
classes: [],
|
|
493
|
+
style: config
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
throw new Error(`Invalid config: ${config}`);
|
|
498
|
+
};
|
|
499
|
+
/**
|
|
500
|
+
* Test harness adapter for adding CSS to the harnessed component wrapper.
|
|
501
|
+
*/
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
const adapter = (children, config) => {
|
|
505
|
+
const {
|
|
506
|
+
classes,
|
|
507
|
+
style
|
|
508
|
+
} = normalizeConfig(config);
|
|
509
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("div", {
|
|
510
|
+
"data-test-id": "css-adapter-container",
|
|
511
|
+
className: classes.join(" "),
|
|
512
|
+
style: style
|
|
513
|
+
}, children);
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
/***/ }),
|
|
517
|
+
/* 9 */
|
|
518
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
519
|
+
|
|
520
|
+
"use strict";
|
|
521
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return defaultConfig; });
|
|
522
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return adapter; });
|
|
523
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
524
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
525
|
+
/* harmony import */ var _khanacademy_wonder_blocks_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(29);
|
|
526
|
+
/* harmony import */ var _khanacademy_wonder_blocks_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_data__WEBPACK_IMPORTED_MODULE_1__);
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Default configuration for the Wonder Blocks Data adapter.
|
|
532
|
+
*/
|
|
533
|
+
const defaultConfig = [];
|
|
534
|
+
/**
|
|
535
|
+
* Test harness adapter to mock Wonder Blocks Data usage.
|
|
536
|
+
*
|
|
537
|
+
* NOTE: Consumers are responsible for properly defining their intercepts.
|
|
538
|
+
* This component does not validate the configuration to ensure interceptors
|
|
539
|
+
* are not overriding one another.
|
|
540
|
+
*/
|
|
541
|
+
|
|
542
|
+
const adapter = (children, config) => {
|
|
543
|
+
// First we render the cache intercepts.
|
|
544
|
+
let currentChildren = children;
|
|
545
|
+
const interceptors = Array.isArray(config) ? config : [config]; // Then we render the data intercepts.
|
|
546
|
+
|
|
547
|
+
for (const interceptor of interceptors) {
|
|
548
|
+
currentChildren = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_data__WEBPACK_IMPORTED_MODULE_1__["InterceptRequests"], {
|
|
549
|
+
interceptor: interceptor
|
|
550
|
+
}, currentChildren);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* `currentChildren` is a `React.Node` but we need it to be a
|
|
554
|
+
* `React.Element<>`. Return it rendered in a fragment allows us to do
|
|
555
|
+
* that.
|
|
556
|
+
*/
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, currentChildren);
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
/***/ }),
|
|
563
|
+
/* 10 */
|
|
564
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
565
|
+
|
|
566
|
+
"use strict";
|
|
567
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return defaultConfig; });
|
|
568
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return adapter; });
|
|
569
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
570
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
571
|
+
|
|
572
|
+
// The default configuration is to omit this adapter.
|
|
573
|
+
const defaultConfig = null;
|
|
574
|
+
/**
|
|
575
|
+
* Test harness adapter for supporting portals.
|
|
576
|
+
*
|
|
577
|
+
* Some components rely on rendering with a React Portal. This adapter ensures
|
|
578
|
+
* that the DOM contains a mounting point for the portal with the expected
|
|
579
|
+
* identifier.
|
|
580
|
+
*/
|
|
581
|
+
|
|
582
|
+
const adapter = (children, config) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("div", {
|
|
583
|
+
id: config,
|
|
584
|
+
"data-test-id": config
|
|
585
|
+
}), children);
|
|
586
|
+
|
|
587
|
+
/***/ }),
|
|
588
|
+
/* 11 */
|
|
589
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
590
|
+
|
|
591
|
+
"use strict";
|
|
592
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return defaultConfig; });
|
|
593
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return adapter; });
|
|
594
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
595
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
596
|
+
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
|
|
597
|
+
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* The default configuration for this adapter.
|
|
603
|
+
*/
|
|
604
|
+
const defaultConfig = {
|
|
605
|
+
location: "/"
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
const maybeWithRoute = (children, path) => {
|
|
609
|
+
if (path == null) {
|
|
610
|
+
return children;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__["Switch"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__["Route"], {
|
|
614
|
+
exact: true,
|
|
615
|
+
path: path
|
|
616
|
+
}, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__["Route"], {
|
|
617
|
+
path: "*",
|
|
618
|
+
render: () => {
|
|
619
|
+
throw new Error("The configured path must match the configured location or your harnessed component will not render.");
|
|
620
|
+
}
|
|
621
|
+
}));
|
|
622
|
+
};
|
|
623
|
+
/**
|
|
624
|
+
* Adapter that sets up a router and AppShell location-specific contexts.
|
|
625
|
+
*
|
|
626
|
+
* This allows you to ensure that components are being tested in the
|
|
627
|
+
* AppShell world.
|
|
628
|
+
*
|
|
629
|
+
* NOTE(somewhatabstract): The AppShell component itself already does
|
|
630
|
+
* the work of setting up routing and the AppShellContext and so using this
|
|
631
|
+
* adapter with the App component will have zero-effect since AppShell will
|
|
632
|
+
* override it.
|
|
633
|
+
*/
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
const adapter = (children, config) => {
|
|
637
|
+
if (typeof config === "string") {
|
|
638
|
+
config = {
|
|
639
|
+
location: config
|
|
640
|
+
};
|
|
641
|
+
} // Wrap children with the various contexts and routes, as per the config.
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
const wrappedWithRoute = maybeWithRoute(children, config.path);
|
|
645
|
+
|
|
646
|
+
if (config.forceStatic) {
|
|
647
|
+
/**
|
|
648
|
+
* There may be times (SSR testing comes to mind) where we will be
|
|
649
|
+
* really strict about not permitting client-side navigation events.
|
|
650
|
+
*/
|
|
651
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__["StaticRouter"], {
|
|
652
|
+
location: config.location,
|
|
653
|
+
context: {}
|
|
654
|
+
}, wrappedWithRoute);
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* OK, we must be OK with a memory router.
|
|
658
|
+
*
|
|
659
|
+
* There are two flavors of config for this. The easy one with just a
|
|
660
|
+
* location, and the complex one for those gnarlier setups.
|
|
661
|
+
*
|
|
662
|
+
* First, the easy one.
|
|
663
|
+
*/
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
if (typeof config.location !== "undefined") {
|
|
667
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__["MemoryRouter"], {
|
|
668
|
+
initialEntries: [config.location]
|
|
669
|
+
}, wrappedWithRoute);
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* If it's not the easy one, it should be the complex one.
|
|
673
|
+
* Let's make sure we have good data (also keeps flow happy).
|
|
674
|
+
*/
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
if (typeof config.initialEntries === "undefined") {
|
|
678
|
+
throw new Error("A location or initial history entries must be provided.");
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* What should happen if no entries were in the array?
|
|
682
|
+
* It likely uses the root one anyway, but a consistent API is what
|
|
683
|
+
* we want, so let's ensure we always have our default location at least.
|
|
684
|
+
*/
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
const entries = config.initialEntries.length === 0 ? [defaultConfig.location] : config.initialEntries; // Memory router doesn't allow us to pass maybe types in its flow types.
|
|
688
|
+
// So let's build props then spread them.
|
|
689
|
+
|
|
690
|
+
const routerProps = {
|
|
691
|
+
initialEntries: entries
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
if (config.initialIndex != null) {
|
|
695
|
+
routerProps.initialIndex = config.initialIndex;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
if (config.getUserConfirmation != null) {
|
|
699
|
+
routerProps.getUserConfirmation = config.getUserConfirmation;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__["MemoryRouter"], routerProps, wrappedWithRoute);
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
/***/ }),
|
|
706
|
+
/* 12 */
|
|
304
707
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
305
708
|
|
|
306
709
|
"use strict";
|
|
307
710
|
__webpack_require__.r(__webpack_exports__);
|
|
308
|
-
/* harmony import */ var _storybook_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
711
|
+
/* harmony import */ var _storybook_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
|
|
309
712
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "storybook", function() { return _storybook_js__WEBPACK_IMPORTED_MODULE_0__["a"]; });
|
|
310
713
|
|
|
311
714
|
|
|
312
715
|
|
|
313
716
|
/***/ }),
|
|
314
|
-
/*
|
|
717
|
+
/* 13 */
|
|
315
718
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
316
719
|
|
|
317
720
|
"use strict";
|
|
318
721
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getAdapter; });
|
|
319
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
722
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
320
723
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
321
|
-
/* harmony import */ var _storybook_addon_actions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
724
|
+
/* harmony import */ var _storybook_addon_actions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(20);
|
|
322
725
|
/* harmony import */ var _storybook_addon_actions__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_storybook_addon_actions__WEBPACK_IMPORTED_MODULE_1__);
|
|
323
|
-
/* harmony import */ var _adapter_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
726
|
+
/* harmony import */ var _adapter_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(21);
|
|
324
727
|
|
|
325
728
|
|
|
326
729
|
|
|
@@ -396,15 +799,15 @@ const getAdapter = (MountingComponent = null) => new _adapter_js__WEBPACK_IMPORT
|
|
|
396
799
|
});
|
|
397
800
|
|
|
398
801
|
/***/ }),
|
|
399
|
-
/*
|
|
802
|
+
/* 14 */
|
|
400
803
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
401
804
|
|
|
402
805
|
"use strict";
|
|
403
806
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return fixtures; });
|
|
404
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
807
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
405
808
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
406
|
-
/* harmony import */ var _setup_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
407
|
-
/* harmony import */ var _combine_options_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
809
|
+
/* harmony import */ var _setup_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
810
|
+
/* harmony import */ var _combine_options_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(23);
|
|
408
811
|
|
|
409
812
|
|
|
410
813
|
|
|
@@ -502,13 +905,13 @@ const fixtures = (componentOrOptions, fn) => {
|
|
|
502
905
|
};
|
|
503
906
|
|
|
504
907
|
/***/ }),
|
|
505
|
-
/*
|
|
908
|
+
/* 15 */
|
|
506
909
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
507
910
|
|
|
508
911
|
"use strict";
|
|
509
912
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return mockFetch; });
|
|
510
|
-
/* harmony import */ var _fetch_request_matches_mock_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
511
|
-
/* harmony import */ var _mock_requester_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
913
|
+
/* harmony import */ var _fetch_request_matches_mock_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26);
|
|
914
|
+
/* harmony import */ var _mock_requester_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
|
512
915
|
|
|
513
916
|
|
|
514
917
|
|
|
@@ -519,13 +922,13 @@ const mockFetch = () => Object(_mock_requester_js__WEBPACK_IMPORTED_MODULE_1__[/
|
|
|
519
922
|
Options: ${init == null ? "None" : JSON.stringify(init, null, 2)}`);
|
|
520
923
|
|
|
521
924
|
/***/ }),
|
|
522
|
-
/*
|
|
925
|
+
/* 16 */
|
|
523
926
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
524
927
|
|
|
525
928
|
"use strict";
|
|
526
929
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return mockGqlFetch; });
|
|
527
|
-
/* harmony import */ var _gql_request_matches_mock_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
528
|
-
/* harmony import */ var _mock_requester_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
930
|
+
/* harmony import */ var _gql_request_matches_mock_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(28);
|
|
931
|
+
/* harmony import */ var _mock_requester_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
|
529
932
|
|
|
530
933
|
|
|
531
934
|
|
|
@@ -537,18 +940,80 @@ const mockGqlFetch = () => Object(_mock_requester_js__WEBPACK_IMPORTED_MODULE_1_
|
|
|
537
940
|
Context: ${JSON.stringify(context, null, 2)}`);
|
|
538
941
|
|
|
539
942
|
/***/ }),
|
|
540
|
-
/*
|
|
943
|
+
/* 17 */
|
|
944
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
945
|
+
|
|
946
|
+
"use strict";
|
|
947
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
948
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* A adapter to be composed with our test harnass infrastructure.
|
|
952
|
+
*/
|
|
953
|
+
|
|
954
|
+
/***/ }),
|
|
955
|
+
/* 18 */
|
|
956
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
957
|
+
|
|
958
|
+
"use strict";
|
|
959
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return hookHarness; });
|
|
960
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
961
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
962
|
+
/* harmony import */ var _make_hook_harness_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
|
|
963
|
+
/* harmony import */ var _adapters_adapters_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Create test wrapper for hook testing with Wonder Blocks default adapters.
|
|
970
|
+
*
|
|
971
|
+
* This is primarily useful for tests within Wonder Blocks.
|
|
972
|
+
*
|
|
973
|
+
* If you want to expand the range of adapters or change the default
|
|
974
|
+
* configurations, use `makeHookHarness` to create a new `hookHarness`
|
|
975
|
+
* function.
|
|
976
|
+
*/
|
|
977
|
+
const hookHarness = Object(_make_hook_harness_js__WEBPACK_IMPORTED_MODULE_1__[/* makeHookHarness */ "a"])(_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_2__["DefaultAdapters"], _adapters_adapters_js__WEBPACK_IMPORTED_MODULE_2__["DefaultConfigs"]);
|
|
978
|
+
|
|
979
|
+
/***/ }),
|
|
980
|
+
/* 19 */
|
|
981
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
982
|
+
|
|
983
|
+
"use strict";
|
|
984
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return testHarness; });
|
|
985
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
986
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
987
|
+
/* harmony import */ var _make_test_harness_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
988
|
+
/* harmony import */ var _adapters_adapters_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Wrap a component with a test harness using Wonder Blocks default adapters.
|
|
995
|
+
*
|
|
996
|
+
* This is primarily useful for tests within Wonder Blocks.
|
|
997
|
+
*
|
|
998
|
+
* If you want to expand the range of adapters or change the default
|
|
999
|
+
* configurations, use `makeTestHarness` to create a new `testHarness`
|
|
1000
|
+
* function.
|
|
1001
|
+
*/
|
|
1002
|
+
const testHarness = Object(_make_test_harness_js__WEBPACK_IMPORTED_MODULE_1__[/* makeTestHarness */ "a"])(_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_2__["DefaultAdapters"], _adapters_adapters_js__WEBPACK_IMPORTED_MODULE_2__["DefaultConfigs"]);
|
|
1003
|
+
|
|
1004
|
+
/***/ }),
|
|
1005
|
+
/* 20 */
|
|
541
1006
|
/***/ (function(module, exports) {
|
|
542
1007
|
|
|
543
1008
|
module.exports = require("@storybook/addon-actions");
|
|
544
1009
|
|
|
545
1010
|
/***/ }),
|
|
546
|
-
/*
|
|
1011
|
+
/* 21 */
|
|
547
1012
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
548
1013
|
|
|
549
1014
|
"use strict";
|
|
550
1015
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Adapter; });
|
|
551
|
-
/* harmony import */ var _adapter_group_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
1016
|
+
/* harmony import */ var _adapter_group_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
|
|
552
1017
|
|
|
553
1018
|
|
|
554
1019
|
/**
|
|
@@ -590,9 +1055,9 @@ class Adapter {
|
|
|
590
1055
|
/**
|
|
591
1056
|
* Declare a new fixture group.
|
|
592
1057
|
*
|
|
593
|
-
* @param {
|
|
1058
|
+
* @param {FixturesAdapterGroupOptions} options The options describing the fixture
|
|
594
1059
|
* group.
|
|
595
|
-
* @returns {
|
|
1060
|
+
* @returns {FixturesAdapterGroup} The new fixture group.
|
|
596
1061
|
*/
|
|
597
1062
|
|
|
598
1063
|
|
|
@@ -603,7 +1068,7 @@ class Adapter {
|
|
|
603
1068
|
}
|
|
604
1069
|
|
|
605
1070
|
/***/ }),
|
|
606
|
-
/*
|
|
1071
|
+
/* 22 */
|
|
607
1072
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
608
1073
|
|
|
609
1074
|
"use strict";
|
|
@@ -668,12 +1133,12 @@ class AdapterGroup {
|
|
|
668
1133
|
}
|
|
669
1134
|
|
|
670
1135
|
/***/ }),
|
|
671
|
-
/*
|
|
1136
|
+
/* 23 */
|
|
672
1137
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
673
1138
|
|
|
674
1139
|
"use strict";
|
|
675
1140
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return combineOptions; });
|
|
676
|
-
/* harmony import */ var _combine_top_level_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
1141
|
+
/* harmony import */ var _combine_top_level_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24);
|
|
677
1142
|
|
|
678
1143
|
/**
|
|
679
1144
|
* Combine one or more objects into a single object.
|
|
@@ -698,12 +1163,12 @@ const combineOptions = (...toBeCombined) => {
|
|
|
698
1163
|
};
|
|
699
1164
|
|
|
700
1165
|
/***/ }),
|
|
701
|
-
/*
|
|
1166
|
+
/* 24 */
|
|
702
1167
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
703
1168
|
|
|
704
1169
|
"use strict";
|
|
705
1170
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return combineTopLevel; });
|
|
706
|
-
/* harmony import */ var _khanacademy_wonder_stuff_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
1171
|
+
/* harmony import */ var _khanacademy_wonder_stuff_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25);
|
|
707
1172
|
/* harmony import */ var _khanacademy_wonder_stuff_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_stuff_core__WEBPACK_IMPORTED_MODULE_0__);
|
|
708
1173
|
|
|
709
1174
|
/**
|
|
@@ -744,26 +1209,13 @@ const combineTopLevel = (val1, val2) => {
|
|
|
744
1209
|
};
|
|
745
1210
|
|
|
746
1211
|
/***/ }),
|
|
747
|
-
/*
|
|
1212
|
+
/* 25 */
|
|
748
1213
|
/***/ (function(module, exports) {
|
|
749
1214
|
|
|
750
1215
|
module.exports = require("@khanacademy/wonder-stuff-core");
|
|
751
1216
|
|
|
752
1217
|
/***/ }),
|
|
753
|
-
/*
|
|
754
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
755
|
-
|
|
756
|
-
"use strict";
|
|
757
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ResponseImpl; });
|
|
758
|
-
// We need a version of Response. When we're in Jest JSDOM environment or a
|
|
759
|
-
// version of Node that supports the fetch API (17 and up, possibly with
|
|
760
|
-
// --experimental-fetch flag), then we're good, but otherwise we need an
|
|
761
|
-
// implementation, so this uses node-fetch as a peer dependency and uses that
|
|
762
|
-
// to provide the implementation if we don't already have one.
|
|
763
|
-
const ResponseImpl = typeof Response === "undefined" ? __webpack_require__(19).Response : Response;
|
|
764
|
-
|
|
765
|
-
/***/ }),
|
|
766
|
-
/* 16 */
|
|
1218
|
+
/* 26 */
|
|
767
1219
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
768
1220
|
|
|
769
1221
|
"use strict";
|
|
@@ -806,7 +1258,20 @@ const fetchRequestMatchesMock = (mock, input, init) => {
|
|
|
806
1258
|
};
|
|
807
1259
|
|
|
808
1260
|
/***/ }),
|
|
809
|
-
/*
|
|
1261
|
+
/* 27 */
|
|
1262
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1263
|
+
|
|
1264
|
+
"use strict";
|
|
1265
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ResponseImpl; });
|
|
1266
|
+
// We need a version of Response. When we're in Jest JSDOM environment or a
|
|
1267
|
+
// version of Node that supports the fetch API (17 and up, possibly with
|
|
1268
|
+
// --experimental-fetch flag), then we're good, but otherwise we need an
|
|
1269
|
+
// implementation, so this uses node-fetch as a peer dependency and uses that
|
|
1270
|
+
// to provide the implementation if we don't already have one.
|
|
1271
|
+
const ResponseImpl = typeof Response === "undefined" ? __webpack_require__(32).Response : Response;
|
|
1272
|
+
|
|
1273
|
+
/***/ }),
|
|
1274
|
+
/* 28 */
|
|
810
1275
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
811
1276
|
|
|
812
1277
|
"use strict";
|
|
@@ -881,39 +1346,101 @@ const gqlRequestMatchesMock = (mock, operation, variables, context) => {
|
|
|
881
1346
|
};
|
|
882
1347
|
|
|
883
1348
|
/***/ }),
|
|
884
|
-
/*
|
|
1349
|
+
/* 29 */
|
|
1350
|
+
/***/ (function(module, exports) {
|
|
1351
|
+
|
|
1352
|
+
module.exports = require("@khanacademy/wonder-blocks-data");
|
|
1353
|
+
|
|
1354
|
+
/***/ }),
|
|
1355
|
+
/* 30 */
|
|
1356
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1357
|
+
|
|
1358
|
+
"use strict";
|
|
1359
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return renderAdapters; });
|
|
1360
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
1361
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* Render test adapters around a child component.
|
|
1366
|
+
*/
|
|
1367
|
+
const renderAdapters = (adapters, configs, children) => {
|
|
1368
|
+
let currentChildren = children;
|
|
1369
|
+
|
|
1370
|
+
for (const adapterName of Object.keys(adapters)) {
|
|
1371
|
+
const adapter = adapters[adapterName];
|
|
1372
|
+
const config = configs[adapterName];
|
|
1373
|
+
/**
|
|
1374
|
+
* Some adapters support a null config, some don't, either way
|
|
1375
|
+
* we always assume that null config means no adapter.
|
|
1376
|
+
*/
|
|
1377
|
+
|
|
1378
|
+
if (config != null) {
|
|
1379
|
+
currentChildren = adapter(currentChildren, config);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
return currentChildren;
|
|
1384
|
+
};
|
|
1385
|
+
|
|
1386
|
+
/***/ }),
|
|
1387
|
+
/* 31 */
|
|
885
1388
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
886
1389
|
|
|
887
1390
|
"use strict";
|
|
888
1391
|
__webpack_require__.r(__webpack_exports__);
|
|
889
|
-
/* harmony import */ var _fixtures_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
890
|
-
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "
|
|
891
|
-
/* harmony import */ var _fixtures_fixtures_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
1392
|
+
/* harmony import */ var _fixtures_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12);
|
|
1393
|
+
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "fixtureAdapters", function() { return _fixtures_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_0__; });
|
|
1394
|
+
/* harmony import */ var _fixtures_fixtures_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(14);
|
|
892
1395
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "fixtures", function() { return _fixtures_fixtures_js__WEBPACK_IMPORTED_MODULE_1__["a"]; });
|
|
893
1396
|
|
|
894
|
-
/* harmony import */ var _fixtures_setup_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
1397
|
+
/* harmony import */ var _fixtures_setup_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
|
895
1398
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "setupFixtures", function() { return _fixtures_setup_js__WEBPACK_IMPORTED_MODULE_2__["b"]; });
|
|
896
1399
|
|
|
897
|
-
/* harmony import */ var
|
|
898
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
1400
|
+
/* harmony import */ var _fetch_mock_fetch_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(15);
|
|
1401
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mockFetch", function() { return _fetch_mock_fetch_js__WEBPACK_IMPORTED_MODULE_3__["a"]; });
|
|
1402
|
+
|
|
1403
|
+
/* harmony import */ var _gql_mock_gql_fetch_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(16);
|
|
1404
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mockGqlFetch", function() { return _gql_mock_gql_fetch_js__WEBPACK_IMPORTED_MODULE_4__["a"]; });
|
|
1405
|
+
|
|
1406
|
+
/* harmony import */ var _make_mock_response_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5);
|
|
1407
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RespondWith", function() { return _make_mock_response_js__WEBPACK_IMPORTED_MODULE_5__["a"]; });
|
|
1408
|
+
|
|
1409
|
+
/* harmony import */ var _harness_types_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(17);
|
|
1410
|
+
/* harmony import */ var _harness_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1);
|
|
1411
|
+
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "harnessAdapters", function() { return _harness_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_7__; });
|
|
1412
|
+
/* harmony import */ var _harness_make_hook_harness_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(6);
|
|
1413
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "makeHookHarness", function() { return _harness_make_hook_harness_js__WEBPACK_IMPORTED_MODULE_8__["a"]; });
|
|
899
1414
|
|
|
900
|
-
/* harmony import */ var
|
|
901
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
1415
|
+
/* harmony import */ var _harness_make_test_harness_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3);
|
|
1416
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "makeTestHarness", function() { return _harness_make_test_harness_js__WEBPACK_IMPORTED_MODULE_9__["a"]; });
|
|
902
1417
|
|
|
903
|
-
/* harmony import */ var
|
|
904
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
1418
|
+
/* harmony import */ var _harness_hook_harness_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(18);
|
|
1419
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "hookHarness", function() { return _harness_hook_harness_js__WEBPACK_IMPORTED_MODULE_10__["a"]; });
|
|
1420
|
+
|
|
1421
|
+
/* harmony import */ var _harness_test_harness_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(19);
|
|
1422
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "testHarness", function() { return _harness_test_harness_js__WEBPACK_IMPORTED_MODULE_11__["a"]; });
|
|
905
1423
|
|
|
906
1424
|
// Fixtures framework
|
|
907
1425
|
|
|
908
1426
|
|
|
909
1427
|
|
|
910
1428
|
|
|
1429
|
+
// Fetch mocking framework
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
// Test harness framework
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
|
|
911
1438
|
|
|
912
1439
|
|
|
913
1440
|
|
|
914
1441
|
|
|
915
1442
|
/***/ }),
|
|
916
|
-
/*
|
|
1443
|
+
/* 32 */
|
|
917
1444
|
/***/ (function(module, exports) {
|
|
918
1445
|
|
|
919
1446
|
module.exports = require("node-fetch");
|