@khanacademy/wonder-blocks-testing 6.1.0 → 7.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/es/index.js +17 -187
  3. package/dist/index.js +90 -463
  4. package/package.json +2 -2
  5. package/src/__docs__/_overview_fixtures.stories.mdx +2 -6
  6. package/src/__docs__/exports.fixtures.stories.mdx +9 -31
  7. package/src/__docs__/types.fixture-fn.stories.mdx +46 -0
  8. package/src/__docs__/types.fixture-props.stories.mdx +20 -0
  9. package/src/fixtures/__tests__/fixtures.test.js +89 -466
  10. package/src/fixtures/fixtures.basic.stories.js +30 -50
  11. package/src/fixtures/fixtures.defaultwrapper.stories.js +26 -40
  12. package/src/fixtures/fixtures.js +50 -103
  13. package/src/fixtures/types.js +15 -181
  14. package/src/index.js +2 -11
  15. package/src/__docs__/exports.fixture-adapters.stories.mdx +0 -49
  16. package/src/__docs__/exports.setup-fixtures.stories.mdx +0 -22
  17. package/src/__docs__/types.custom-mount-props.stories.mdx +0 -35
  18. package/src/__docs__/types.fixtures-adapter-factory.stories.mdx +0 -23
  19. package/src/__docs__/types.fixtures-adapter-fixture-options.stories.mdx +0 -35
  20. package/src/__docs__/types.fixtures-adapter-group-options.stories.mdx +0 -37
  21. package/src/__docs__/types.fixtures-adapter-group.stories.mdx +0 -43
  22. package/src/__docs__/types.fixtures-adapter-options.stories.mdx +0 -21
  23. package/src/__docs__/types.fixtures-adapter.stories.mdx +0 -35
  24. package/src/__docs__/types.fixtures-configuration.stories.mdx +0 -35
  25. package/src/__docs__/types.fixtures-options.stories.mdx +0 -51
  26. package/src/fixtures/__tests__/combine-options.test.js +0 -65
  27. package/src/fixtures/__tests__/combine-top-level.test.js +0 -100
  28. package/src/fixtures/__tests__/setup.test.js +0 -71
  29. package/src/fixtures/adapters/__tests__/__snapshots__/adapter-group.test.js.snap +0 -9
  30. package/src/fixtures/adapters/__tests__/__snapshots__/adapter.test.js.snap +0 -13
  31. package/src/fixtures/adapters/__tests__/adapter-group.test.js +0 -223
  32. package/src/fixtures/adapters/__tests__/adapter.test.js +0 -97
  33. package/src/fixtures/adapters/__tests__/storybook.test.js +0 -369
  34. package/src/fixtures/adapters/adapter-group.js +0 -88
  35. package/src/fixtures/adapters/adapter.js +0 -63
  36. package/src/fixtures/adapters/adapters.js +0 -2
  37. package/src/fixtures/adapters/storybook.js +0 -128
  38. package/src/fixtures/combine-options.js +0 -25
  39. package/src/fixtures/combine-top-level.js +0 -44
  40. package/src/fixtures/setup.js +0 -30
package/dist/index.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 31);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 23);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ([
@@ -99,10 +99,10 @@ module.exports = require("react");
99
99
  __webpack_require__.r(__webpack_exports__);
100
100
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultAdapters", function() { return DefaultAdapters; });
101
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__(9);
103
- /* harmony import */ var _data_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(10);
104
- /* harmony import */ var _portal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
105
- /* harmony import */ var _router_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12);
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
106
 
107
107
 
108
108
 
@@ -148,7 +148,7 @@ module.exports = require("react-router-dom");
148
148
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return makeTestHarness; });
149
149
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
150
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);
151
+ /* harmony import */ var _render_adapters_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(22);
152
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
153
 
154
154
 
@@ -202,40 +202,10 @@ const makeTestHarness = (adapters, defaultConfigs) => {
202
202
  /* 4 */
203
203
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
204
204
 
205
- "use strict";
206
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return setup; });
207
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getConfiguration; });
208
- let _configuration = null;
209
- /**
210
- * Setup the fixture framework.
211
- */
212
-
213
- const setup = configuration => {
214
- _configuration = configuration;
215
- };
216
- /**
217
- * Get the framework configuration.
218
- *
219
- * @returns {Configuration} The configuration as provided via setup().
220
- * @throws {Error} If the configuration has not been set.
221
- */
222
-
223
- const getConfiguration = () => {
224
- if (_configuration == null) {
225
- throw new Error("Not configured");
226
- }
227
-
228
- return _configuration;
229
- };
230
-
231
- /***/ }),
232
- /* 5 */
233
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
234
-
235
205
  "use strict";
236
206
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return RespondWith; });
237
207
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return makeMockResponse; });
238
- /* harmony import */ var _response_impl_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(27);
208
+ /* harmony import */ var _response_impl_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19);
239
209
 
240
210
 
241
211
  /**
@@ -349,7 +319,7 @@ const makeMockResponse = response => {
349
319
  };
350
320
 
351
321
  /***/ }),
352
- /* 6 */
322
+ /* 5 */
353
323
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
354
324
 
355
325
  "use strict";
@@ -392,12 +362,12 @@ const makeHookHarness = (adapters, defaultConfigs) => {
392
362
  };
393
363
 
394
364
  /***/ }),
395
- /* 7 */
365
+ /* 6 */
396
366
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
397
367
 
398
368
  "use strict";
399
369
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return mockRequester; });
400
- /* harmony import */ var _make_mock_response_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
370
+ /* harmony import */ var _make_mock_response_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
401
371
 
402
372
 
403
373
  /**
@@ -450,13 +420,13 @@ const mockRequester = (operationMatcher, operationToString) => {
450
420
  };
451
421
 
452
422
  /***/ }),
453
- /* 8 */
423
+ /* 7 */
454
424
  /***/ (function(module, exports) {
455
425
 
456
426
  module.exports = require("@storybook/addon-actions");
457
427
 
458
428
  /***/ }),
459
- /* 9 */
429
+ /* 8 */
460
430
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
461
431
 
462
432
  "use strict";
@@ -520,7 +490,7 @@ const adapter = (children, config) => {
520
490
  };
521
491
 
522
492
  /***/ }),
523
- /* 10 */
493
+ /* 9 */
524
494
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
525
495
 
526
496
  "use strict";
@@ -528,7 +498,7 @@ const adapter = (children, config) => {
528
498
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return adapter; });
529
499
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
530
500
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
531
- /* harmony import */ var _khanacademy_wonder_blocks_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(29);
501
+ /* harmony import */ var _khanacademy_wonder_blocks_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(21);
532
502
  /* harmony import */ var _khanacademy_wonder_blocks_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_data__WEBPACK_IMPORTED_MODULE_1__);
533
503
 
534
504
 
@@ -566,7 +536,7 @@ const adapter = (children, config) => {
566
536
  };
567
537
 
568
538
  /***/ }),
569
- /* 11 */
539
+ /* 10 */
570
540
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
571
541
 
572
542
  "use strict";
@@ -591,7 +561,7 @@ const adapter = (children, config) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODUL
591
561
  }), children);
592
562
 
593
563
  /***/ }),
594
- /* 12 */
564
+ /* 11 */
595
565
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
596
566
 
597
567
  "use strict";
@@ -709,214 +679,86 @@ const adapter = (children, config) => {
709
679
  };
710
680
 
711
681
  /***/ }),
712
- /* 13 */
713
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
714
-
715
- "use strict";
716
- __webpack_require__.r(__webpack_exports__);
717
- /* harmony import */ var _storybook_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14);
718
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "storybook", function() { return _storybook_js__WEBPACK_IMPORTED_MODULE_0__["a"]; });
719
-
720
-
721
-
722
- /***/ }),
723
- /* 14 */
682
+ /* 12 */
724
683
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
725
684
 
726
685
  "use strict";
727
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getAdapter; });
686
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return fixtures; });
728
687
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
729
688
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
730
- /* harmony import */ var _storybook_addon_actions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
689
+ /* harmony import */ var _storybook_addon_actions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
731
690
  /* harmony import */ var _storybook_addon_actions__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_storybook_addon_actions__WEBPACK_IMPORTED_MODULE_1__);
732
- /* harmony import */ var _adapter_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(21);
733
-
734
691
 
735
692
 
736
693
 
737
694
  /**
738
- * Get a fixture framework adapter for Storybook support.
695
+ * Describe a group of fixtures for a given component.
696
+ *
697
+ * Only one `fixtures` call should be used per fixture file as it returns
698
+ * the exports for that file.
699
+ *
700
+ * @param {component: React.ComponentType<any>} options Options describing the
701
+ * fixture group.
702
+ * @param {FixtureFn<TProps> => void} fn A function that provides a `fixture`
703
+ * function for defining fixtures.
704
+ * @returns {(
705
+ * description: string,
706
+ * props: FixtureProps<TProps>,
707
+ * wrapper?: React.ComponentType<TProps>,
708
+ * ) => mixed} A function to create a CSF compatible story.
739
709
  */
740
- const getAdapter = (MountingComponent = null) => new _adapter_js__WEBPACK_IMPORTED_MODULE_2__[/* Adapter */ "a"]("storybook", ({
741
- title,
742
- description: groupDescription,
743
- // We don't use the default title in Storybook as storybook
744
- // will generate titles for us if we pass a nullish title.
745
- getDefaultTitle: _
746
- }, adapterOptions, declaredFixtures) => {
747
- const templateMap = new WeakMap();
710
+ const fixtures = Component => {
711
+ const templateMap = new WeakMap(); // We use this to make sure each story gets a unique name.
712
+
713
+ let storyNumber = 1;
748
714
  const getPropsOptions = {
749
715
  log: (message, ...args) => Object(_storybook_addon_actions__WEBPACK_IMPORTED_MODULE_1__["action"])(message).apply(void 0, args),
750
716
  logHandler: _storybook_addon_actions__WEBPACK_IMPORTED_MODULE_1__["action"]
751
717
  };
752
- const exports = declaredFixtures.reduce((acc, {
753
- description,
754
- getProps,
755
- component: Component
756
- }, i) => {
757
- const storyName = `${i + 1} ${description}`;
758
- const exportName = storyName // Make word boundaries start with an upper case letter.
759
- .replace(/\b\w/g, c => c.toUpperCase()) // Remove all non-alphanumeric characters.
760
- .replace(/[^\w]+/g, "") // Remove all underscores.
761
- .replace(/[_]+/g, ""); // We create a “template” of how args map to rendering
718
+
719
+ const makeStory = (description, props, wrapper = null) => {
720
+ const storyName = `${storyNumber++} ${description}`;
721
+
722
+ const getProps = options => typeof props === "function" ? props(options) : props;
723
+
724
+ const RealComponent = wrapper || Component; // We create a “template” of how args map to rendering
762
725
  // for each type of component as the component here could
763
726
  // be the component under test, or wrapped in a wrapper
764
727
  // component. We don't use decorators for the wrapper
765
728
  // because we may not be in a storybook context and it
766
729
  // keeps the framework API simpler this way.
767
730
 
768
- let Template = templateMap.get(Component);
731
+ let Template = templateMap.get(RealComponent);
769
732
 
770
733
  if (Template == null) {
771
- // The MountingComponent is a bit different than just a
772
- // Storybook decorator. It's a React component that
773
- // takes over rendering the component in the fixture
774
- // with the given args, allowing for greater
775
- // customization in a platform-agnostic manner (i.e.
776
- // not just story format).
777
- Template = MountingComponent ? args => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](MountingComponent, {
778
- component: Component,
779
- props: args,
780
- log: getPropsOptions.log
781
- }) : args => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](Component, args);
782
- templateMap.set(Component, Template);
734
+ Template = args => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](RealComponent, args);
735
+
736
+ templateMap.set(RealComponent, Template);
783
737
  } // Each story that shares that component then reuses that
784
738
  // template.
785
739
 
786
740
 
787
- acc[exportName] = Template.bind({});
788
- acc[exportName].args = getProps(getPropsOptions); // Adding a story name here means that we don't have to
741
+ const story = Template.bind({});
742
+ story.args = getProps(getPropsOptions); // Adding a story name here means that we don't have to
789
743
  // care about naming the exports correctly, if we don't
790
744
  // want (useful if we need to autogenerate or manually
791
745
  // expose ESM exports).
792
746
 
793
- acc[exportName].storyName = storyName;
794
- return acc;
795
- }, {
796
- default: {
797
- title,
798
- // TODO(somewhatabstract): Use groupDescription
799
- // Possibly via a decorator?
800
- ...adapterOptions
801
- }
802
- });
803
- return Object.freeze(exports);
804
- });
805
-
806
- /***/ }),
807
- /* 15 */
808
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
809
-
810
- "use strict";
811
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return fixtures; });
812
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
813
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
814
- /* harmony import */ var _setup_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
815
- /* harmony import */ var _combine_options_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(23);
816
-
817
-
818
-
819
-
820
- const normalizeOptions = componentOrOptions => {
821
- // To differentiate between a React component and a FixturesOptions object,
822
- // we have to do some type checking.
823
- //
824
- // Alternatives I considered were:
825
- // - Use an additional parameter for the options and then do an arg number
826
- // check, but that always makes typing a function harder and often breaks
827
- // types. I didn't want that battle today.
828
- // - Use a tuple when providing component and options with the first element
829
- // being the component and the second being the options. However that
830
- // feels like an obscure API even though it's really easy to do the
831
- // typing.
832
- if ( // Most React components, whether functional or class-based, are
833
- // inherently functions in JavaScript, so a check for functions is
834
- // usually sufficient.
835
- typeof componentOrOptions === "function" || // However, the return of React.forwardRef is not a function,
836
- // so we also have to cope with that.
837
- // A forwardRef has $$typeof = Symbol(react.forward_ref) and a
838
- // render function.
839
- // $FlowIgnore[prop-missing]
840
- typeof componentOrOptions.render === "function") {
841
- return {
842
- // $FlowIgnore[incompatible-return]
843
- component: componentOrOptions
844
- };
845
- } // We can't test for React.ComponentType at runtime.
846
- // Let's assume our simple heuristic above is sufficient.
847
- // $FlowIgnore[incompatible-return]
848
-
849
-
850
- return componentOrOptions;
851
- };
852
- /**
853
- * Describe a group of fixtures for a given component.
854
- *
855
- * Only one `fixtures` call should be used per fixture file as it returns
856
- * the exports for that file.
857
- *
858
- * @param {FixtureOptions<TProps>} options Options describing the
859
- * fixture group.
860
- * @param {FixtureFn<TProps> => void} fn A function that provides a `fixture`
861
- * function for defining fixtures.
862
- * @returns {Exports} The object to be exported as `module.exports`.
863
- *
864
- * TODO(somewhatabstract): Determine a way around this requirement so we
865
- * can support named exports and default exports via the adapters in a
866
- * deterministic way. Currently this is imposed on us because of how
867
- * storybook, the popular framework, uses both default and named exports for
868
- * its interface.
869
- */
870
-
871
-
872
- const fixtures = (componentOrOptions, fn) => {
873
- var _additionalAdapterOpt;
874
-
875
- const {
876
- adapter,
877
- defaultAdapterOptions
878
- } = Object(_setup_js__WEBPACK_IMPORTED_MODULE_1__[/* getConfiguration */ "a"])();
879
- const {
880
- title,
881
- component,
882
- description: groupDescription,
883
- defaultWrapper,
884
- additionalAdapterOptions
885
- } = normalizeOptions(componentOrOptions); // 1. Create a new adapter group.
886
-
887
- const group = adapter.declareGroup({
888
- title,
889
- description: groupDescription,
890
- getDefaultTitle: () => component.displayName || component.name || "Component"
891
- }); // 2. Invoke fn with a function that can add a new fixture.
892
-
893
- const addFixture = (description, props, wrapper = null) => {
894
- var _ref;
895
-
896
- group.declareFixture({
897
- description,
898
- getProps: options => typeof props === "function" ? props(options) : props,
899
- component: (_ref = wrapper != null ? wrapper : defaultWrapper) != null ? _ref : component
900
- });
747
+ story.storyName = storyName;
748
+ return story;
901
749
  };
902
750
 
903
- fn(addFixture); // 3. Combine the adapter options from the fixture group with the
904
- // defaults from our setup.
905
-
906
- const groupAdapterOverrides = (_additionalAdapterOpt = additionalAdapterOptions == null ? void 0 : additionalAdapterOptions[adapter.name]) != null ? _additionalAdapterOpt : {};
907
- const combinedAdapterOptions = Object(_combine_options_js__WEBPACK_IMPORTED_MODULE_2__[/* combineOptions */ "a"])(defaultAdapterOptions, groupAdapterOverrides); // 4. Call close on the group and return the result.
908
-
909
- return group.closeGroup(combinedAdapterOptions);
751
+ return makeStory;
910
752
  };
911
753
 
912
754
  /***/ }),
913
- /* 16 */
755
+ /* 13 */
914
756
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
915
757
 
916
758
  "use strict";
917
759
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return mockFetch; });
918
- /* harmony import */ var _fetch_request_matches_mock_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26);
919
- /* harmony import */ var _mock_requester_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
760
+ /* harmony import */ var _fetch_request_matches_mock_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
761
+ /* harmony import */ var _mock_requester_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
920
762
 
921
763
 
922
764
 
@@ -927,13 +769,13 @@ const mockFetch = () => Object(_mock_requester_js__WEBPACK_IMPORTED_MODULE_1__[/
927
769
  Options: ${init == null ? "None" : JSON.stringify(init, null, 2)}`);
928
770
 
929
771
  /***/ }),
930
- /* 17 */
772
+ /* 14 */
931
773
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
932
774
 
933
775
  "use strict";
934
776
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return mockGqlFetch; });
935
- /* harmony import */ var _gql_request_matches_mock_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(28);
936
- /* harmony import */ var _mock_requester_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
777
+ /* harmony import */ var _gql_request_matches_mock_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20);
778
+ /* harmony import */ var _mock_requester_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
937
779
 
938
780
 
939
781
 
@@ -945,7 +787,7 @@ const mockGqlFetch = () => Object(_mock_requester_js__WEBPACK_IMPORTED_MODULE_1_
945
787
  Context: ${JSON.stringify(context, null, 2)}`);
946
788
 
947
789
  /***/ }),
948
- /* 18 */
790
+ /* 15 */
949
791
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
950
792
 
951
793
  "use strict";
@@ -957,14 +799,14 @@ const mockGqlFetch = () => Object(_mock_requester_js__WEBPACK_IMPORTED_MODULE_1_
957
799
  */
958
800
 
959
801
  /***/ }),
960
- /* 19 */
802
+ /* 16 */
961
803
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
962
804
 
963
805
  "use strict";
964
806
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return hookHarness; });
965
807
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
966
808
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
967
- /* harmony import */ var _make_hook_harness_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
809
+ /* harmony import */ var _make_hook_harness_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
968
810
  /* harmony import */ var _adapters_adapters_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
969
811
 
970
812
 
@@ -982,7 +824,7 @@ const mockGqlFetch = () => Object(_mock_requester_js__WEBPACK_IMPORTED_MODULE_1_
982
824
  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"]);
983
825
 
984
826
  /***/ }),
985
- /* 20 */
827
+ /* 17 */
986
828
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
987
829
 
988
830
  "use strict";
@@ -1007,214 +849,7 @@ const hookHarness = Object(_make_hook_harness_js__WEBPACK_IMPORTED_MODULE_1__[/*
1007
849
  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"]);
1008
850
 
1009
851
  /***/ }),
1010
- /* 21 */
1011
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1012
-
1013
- "use strict";
1014
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Adapter; });
1015
- /* harmony import */ var _adapter_group_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
1016
-
1017
-
1018
- /**
1019
- * Class for implementing a custom adapter.
1020
- */
1021
- class Adapter {
1022
- /**
1023
- * @param {string} name The name of the adapter.
1024
- * @param {CloseGroupFn<any, Options, Exports>} closeGroupFn The function
1025
- * an adapter group should call when the group is closed. This is invoked
1026
- * by an adapter group when it is closed. This function is where an
1027
- * adapter implements the logic to generate the actual fixtures for the
1028
- * adapter's target framework.
1029
- */
1030
- constructor(name, closeGroupFn) {
1031
- if (typeof name !== "string") {
1032
- throw new TypeError("name must be a string");
1033
- }
1034
-
1035
- if (name.trim() === "") {
1036
- throw new Error("name must be a non-empty string");
1037
- }
1038
-
1039
- if (typeof closeGroupFn !== "function") {
1040
- throw new TypeError("closeGroupFn must be a function");
1041
- }
1042
-
1043
- this._name = name;
1044
- this._closeGroupFn = closeGroupFn;
1045
- }
1046
- /**
1047
- * The name of the adapter.
1048
- */
1049
-
1050
-
1051
- get name() {
1052
- return this._name;
1053
- }
1054
- /**
1055
- * Declare a new fixture group.
1056
- *
1057
- * @param {FixturesAdapterGroupOptions} options The options describing the fixture
1058
- * group.
1059
- * @returns {FixturesAdapterGroup} The new fixture group.
1060
- */
1061
-
1062
-
1063
- declareGroup(options) {
1064
- return new _adapter_group_js__WEBPACK_IMPORTED_MODULE_0__[/* AdapterGroup */ "a"](this._closeGroupFn, options);
1065
- }
1066
-
1067
- }
1068
-
1069
- /***/ }),
1070
- /* 22 */
1071
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1072
-
1073
- "use strict";
1074
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AdapterGroup; });
1075
- /**
1076
- * Simple adapter group implementation.
1077
- */
1078
- class AdapterGroup {
1079
- /**
1080
- * Create an adapter group.
1081
- *
1082
- * @param {CloseGroupFn<TProps, Options, Exports>} closeGroupFn A function
1083
- * to invoke when the group is closed.
1084
- * @param {AdapterGroupOptions} options The options for the group.
1085
- */
1086
- constructor(closeGroupFn, _options) {
1087
- this.closeGroup = (adapterOptions = null) => {
1088
- if (this._closeGroupFn == null) {
1089
- throw new Error("Group already closed");
1090
- }
1091
-
1092
- try {
1093
- return this._closeGroupFn(this._options, adapterOptions, this._fixtures);
1094
- } finally {
1095
- this._closeGroupFn = null;
1096
- }
1097
- };
1098
-
1099
- this.declareFixture = options => {
1100
- if (typeof options !== "object" || options === null) {
1101
- throw new TypeError("options must be an object");
1102
- }
1103
-
1104
- if (this._closeGroupFn == null) {
1105
- throw new Error("Cannot declare fixtures after closing the group");
1106
- }
1107
-
1108
- this._fixtures.push(options);
1109
- };
1110
-
1111
- if (typeof closeGroupFn !== "function") {
1112
- throw new TypeError("closeGroupFn must be a function");
1113
- }
1114
-
1115
- if (typeof _options !== "object" || _options === null) {
1116
- throw new TypeError("options must be an object");
1117
- }
1118
-
1119
- this._closeGroupFn = closeGroupFn;
1120
- this._options = _options;
1121
- this._fixtures = [];
1122
- }
1123
- /**
1124
- * Close the group.
1125
- *
1126
- * This declares that no more fixtures are to be added to the group,
1127
- * and will call the parent adapter with the declared fixtures so that they
1128
- * can be adapted for the target fixture framework, such as Storybook.
1129
- */
1130
-
1131
-
1132
- }
1133
-
1134
- /***/ }),
1135
- /* 23 */
1136
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1137
-
1138
- "use strict";
1139
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return combineOptions; });
1140
- /* harmony import */ var _combine_top_level_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24);
1141
-
1142
- /**
1143
- * Combine one or more objects into a single object.
1144
- *
1145
- * Objects later in the argument list take precedence over those that are
1146
- * earlier. Object and array values at the root level are merged.
1147
- */
1148
-
1149
- const combineOptions = (...toBeCombined) => {
1150
- const combined = toBeCombined.filter(Boolean).reduce((acc, cur) => {
1151
- for (const key of Object.keys(cur)) {
1152
- // We always call combine, even if acc[key] is undefined
1153
- // because we need to make sure we clone values.
1154
- acc[key] = Object(_combine_top_level_js__WEBPACK_IMPORTED_MODULE_0__[/* combineTopLevel */ "a"])(acc[key], cur[key]);
1155
- }
1156
-
1157
- return acc;
1158
- }, {}); // We know that we are creating a compatible return type.
1159
- // $FlowIgnore[incompatible-return]
1160
-
1161
- return combined;
1162
- };
1163
-
1164
- /***/ }),
1165
- /* 24 */
1166
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1167
-
1168
- "use strict";
1169
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return combineTopLevel; });
1170
- /* harmony import */ var _khanacademy_wonder_stuff_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25);
1171
- /* harmony import */ var _khanacademy_wonder_stuff_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_stuff_core__WEBPACK_IMPORTED_MODULE_0__);
1172
-
1173
- /**
1174
- * Combine two values.
1175
- *
1176
- * This method clones val2 before using any of its properties to try to ensure
1177
- * the combined object is not linked back to the original.
1178
- *
1179
- * If the values are objects, it will merge them at the top level. Properties
1180
- * themselves are not merged; val2 properties will overwrite val1 where there
1181
- * are conflicts
1182
- *
1183
- * If the values are arrays, it will concatenate and dedupe them.
1184
- * NOTE: duplicates in either val1 or val2 will also be deduped.
1185
- *
1186
- * If the values are any other type, or val2 has a different type to val1, val2
1187
- * will be returned.
1188
- */
1189
-
1190
- const combineTopLevel = (val1, val2) => {
1191
- const obj2Clone = Object(_khanacademy_wonder_stuff_core__WEBPACK_IMPORTED_MODULE_0__["clone"])(val2); // Only merge if they're both arrays or both objects.
1192
- // If not, we will just return val2.
1193
-
1194
- if (val1 !== null && val2 !== null && typeof val1 === "object" && typeof val2 === "object") {
1195
- const val1IsArray = Array.isArray(val1);
1196
- const val2IsArray = Array.isArray(val2);
1197
-
1198
- if (val1IsArray && val2IsArray) {
1199
- return Array.from(new Set([].concat(val1, obj2Clone)));
1200
- } else if (!val1IsArray && !val2IsArray) {
1201
- return { ...val1,
1202
- ...obj2Clone
1203
- };
1204
- }
1205
- }
1206
-
1207
- return obj2Clone;
1208
- };
1209
-
1210
- /***/ }),
1211
- /* 25 */
1212
- /***/ (function(module, exports) {
1213
-
1214
- module.exports = require("@khanacademy/wonder-stuff-core");
1215
-
1216
- /***/ }),
1217
- /* 26 */
852
+ /* 18 */
1218
853
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1219
854
 
1220
855
  "use strict";
@@ -1257,7 +892,7 @@ const fetchRequestMatchesMock = (mock, input, init) => {
1257
892
  };
1258
893
 
1259
894
  /***/ }),
1260
- /* 27 */
895
+ /* 19 */
1261
896
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1262
897
 
1263
898
  "use strict";
@@ -1267,10 +902,10 @@ const fetchRequestMatchesMock = (mock, input, init) => {
1267
902
  // --experimental-fetch flag), then we're good, but otherwise we need an
1268
903
  // implementation, so this uses node-fetch as a peer dependency and uses that
1269
904
  // to provide the implementation if we don't already have one.
1270
- const ResponseImpl = typeof Response === "undefined" ? __webpack_require__(32).Response : Response;
905
+ const ResponseImpl = typeof Response === "undefined" ? __webpack_require__(24).Response : Response;
1271
906
 
1272
907
  /***/ }),
1273
- /* 28 */
908
+ /* 20 */
1274
909
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1275
910
 
1276
911
  "use strict";
@@ -1345,13 +980,13 @@ const gqlRequestMatchesMock = (mock, operation, variables, context) => {
1345
980
  };
1346
981
 
1347
982
  /***/ }),
1348
- /* 29 */
983
+ /* 21 */
1349
984
  /***/ (function(module, exports) {
1350
985
 
1351
986
  module.exports = require("@khanacademy/wonder-blocks-data");
1352
987
 
1353
988
  /***/ }),
1354
- /* 30 */
989
+ /* 22 */
1355
990
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1356
991
 
1357
992
  "use strict";
@@ -1383,48 +1018,40 @@ const renderAdapters = (adapters, configs, children) => {
1383
1018
  };
1384
1019
 
1385
1020
  /***/ }),
1386
- /* 31 */
1021
+ /* 23 */
1387
1022
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1388
1023
 
1389
1024
  "use strict";
1390
1025
  __webpack_require__.r(__webpack_exports__);
1391
- /* harmony import */ var _fixtures_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
1392
- /* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "fixtureAdapters", function() { return _fixtures_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_0__; });
1393
- /* harmony import */ var _fixtures_fixtures_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15);
1394
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "fixtures", function() { return _fixtures_fixtures_js__WEBPACK_IMPORTED_MODULE_1__["a"]; });
1395
-
1396
- /* harmony import */ var _fixtures_setup_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
1397
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "setupFixtures", function() { return _fixtures_setup_js__WEBPACK_IMPORTED_MODULE_2__["b"]; });
1026
+ /* harmony import */ var _fixtures_fixtures_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12);
1027
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "fixtures", function() { return _fixtures_fixtures_js__WEBPACK_IMPORTED_MODULE_0__["a"]; });
1398
1028
 
1399
- /* harmony import */ var _fetch_mock_fetch_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(16);
1400
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mockFetch", function() { return _fetch_mock_fetch_js__WEBPACK_IMPORTED_MODULE_3__["a"]; });
1029
+ /* harmony import */ var _fetch_mock_fetch_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(13);
1030
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mockFetch", function() { return _fetch_mock_fetch_js__WEBPACK_IMPORTED_MODULE_1__["a"]; });
1401
1031
 
1402
- /* harmony import */ var _gql_mock_gql_fetch_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(17);
1403
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mockGqlFetch", function() { return _gql_mock_gql_fetch_js__WEBPACK_IMPORTED_MODULE_4__["a"]; });
1032
+ /* harmony import */ var _gql_mock_gql_fetch_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(14);
1033
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mockGqlFetch", function() { return _gql_mock_gql_fetch_js__WEBPACK_IMPORTED_MODULE_2__["a"]; });
1404
1034
 
1405
- /* harmony import */ var _make_mock_response_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5);
1406
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RespondWith", function() { return _make_mock_response_js__WEBPACK_IMPORTED_MODULE_5__["a"]; });
1035
+ /* harmony import */ var _make_mock_response_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
1036
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RespondWith", function() { return _make_mock_response_js__WEBPACK_IMPORTED_MODULE_3__["a"]; });
1407
1037
 
1408
- /* harmony import */ var _harness_types_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(18);
1409
- /* harmony import */ var _harness_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1);
1410
- /* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "harnessAdapters", function() { return _harness_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_7__; });
1411
- /* harmony import */ var _harness_make_hook_harness_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(6);
1412
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "makeHookHarness", function() { return _harness_make_hook_harness_js__WEBPACK_IMPORTED_MODULE_8__["a"]; });
1038
+ /* harmony import */ var _harness_types_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(15);
1039
+ /* harmony import */ var _harness_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1);
1040
+ /* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "harnessAdapters", function() { return _harness_adapters_adapters_js__WEBPACK_IMPORTED_MODULE_5__; });
1041
+ /* harmony import */ var _harness_make_hook_harness_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5);
1042
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "makeHookHarness", function() { return _harness_make_hook_harness_js__WEBPACK_IMPORTED_MODULE_6__["a"]; });
1413
1043
 
1414
- /* harmony import */ var _harness_make_test_harness_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3);
1415
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "makeTestHarness", function() { return _harness_make_test_harness_js__WEBPACK_IMPORTED_MODULE_9__["a"]; });
1044
+ /* harmony import */ var _harness_make_test_harness_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(3);
1045
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "makeTestHarness", function() { return _harness_make_test_harness_js__WEBPACK_IMPORTED_MODULE_7__["a"]; });
1416
1046
 
1417
- /* harmony import */ var _harness_hook_harness_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(19);
1418
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "hookHarness", function() { return _harness_hook_harness_js__WEBPACK_IMPORTED_MODULE_10__["a"]; });
1047
+ /* harmony import */ var _harness_hook_harness_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(16);
1048
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "hookHarness", function() { return _harness_hook_harness_js__WEBPACK_IMPORTED_MODULE_8__["a"]; });
1419
1049
 
1420
- /* harmony import */ var _harness_test_harness_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(20);
1421
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "testHarness", function() { return _harness_test_harness_js__WEBPACK_IMPORTED_MODULE_11__["a"]; });
1050
+ /* harmony import */ var _harness_test_harness_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(17);
1051
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "testHarness", function() { return _harness_test_harness_js__WEBPACK_IMPORTED_MODULE_9__["a"]; });
1422
1052
 
1423
1053
  // Fixtures framework
1424
1054
 
1425
-
1426
-
1427
-
1428
1055
  // Fetch mocking framework
1429
1056
 
1430
1057
 
@@ -1439,7 +1066,7 @@ __webpack_require__.r(__webpack_exports__);
1439
1066
 
1440
1067
 
1441
1068
  /***/ }),
1442
- /* 32 */
1069
+ /* 24 */
1443
1070
  /***/ (function(module, exports) {
1444
1071
 
1445
1072
  module.exports = require("node-fetch");