@khanacademy/wonder-blocks-testing-core 2.0.0 → 2.1.0

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 CHANGED
@@ -1,32 +1,47 @@
1
1
  # @khanacademy/wonder-blocks-testing-core
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f03298f: Tooling:
8
+
9
+ - Switching to `pnpm`.
10
+ - Upgrading `rollup` to v4 and `@babel/runtime` to match the current webapp version.
11
+
12
+ ## 2.0.1
13
+
14
+ ### Patch Changes
15
+
16
+ - 11a0f5c6: No functional changes. Adding prepublishOnly script.
17
+
3
18
  ## 2.0.0
4
19
 
5
20
  ### Major Changes
6
21
 
7
- - e6abdd17: Upgrade to React 18
22
+ - e6abdd17: Upgrade to React 18
8
23
 
9
24
  ## 1.1.0
10
25
 
11
26
  ### Minor Changes
12
27
 
13
- - 16565a85: Add support for hard fails to the request mocking features
28
+ - 16565a85: Add support for hard fails to the request mocking features
14
29
 
15
30
  ## 1.0.2
16
31
 
17
32
  ### Patch Changes
18
33
 
19
- - 02a1b298: Make sure we don't package tsconfig and tsbuildinfo files
34
+ - 02a1b298: Make sure we don't package tsconfig and tsbuildinfo files
20
35
 
21
36
  ## 1.0.1
22
37
 
23
38
  ### Patch Changes
24
39
 
25
- - c954464a: Fix how react-dom/server is imported in Wonder Blocks Testing Core
26
- - 559e82d5: Update to build tooling, generating smaller output
40
+ - c954464a: Fix how react-dom/server is imported in Wonder Blocks Testing Core
41
+ - 559e82d5: Update to build tooling, generating smaller output
27
42
 
28
43
  ## 1.0.0
29
44
 
30
45
  ### Major Changes
31
46
 
32
- - 2a6c85df: New package containing core Testing functionality without dependencies on other WB packages
47
+ - 2a6c85df: New package containing core Testing functionality without dependencies on other WB packages
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Khan Academy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/es/index.js CHANGED
@@ -193,7 +193,7 @@ class SettleSignal extends EventTarget {
193
193
  constructor(setSettleFn = null) {
194
194
  super();
195
195
  this._settled = false;
196
- setSettleFn == null ? void 0 : setSettleFn(() => {
196
+ setSettleFn == null || setSettleFn(() => {
197
197
  if (this._settled) {
198
198
  throw new Error("SettleSignal already settled");
199
199
  }
@@ -213,8 +213,8 @@ class SettleSignal extends EventTarget {
213
213
 
214
214
  class SettleController {
215
215
  constructor() {
216
- this._settleFn = void 0;
217
- this._signal = void 0;
216
+ this._settleFn = undefined;
217
+ this._signal = undefined;
218
218
  this._signal = new SettleSignal(settleFn => this._settleFn = settleFn);
219
219
  }
220
220
  get signal() {
@@ -222,7 +222,7 @@ class SettleController {
222
222
  }
223
223
  settle() {
224
224
  var _this$_settleFn;
225
- (_this$_settleFn = this._settleFn) == null ? void 0 : _this$_settleFn.call(this);
225
+ (_this$_settleFn = this._settleFn) == null || _this$_settleFn.call(this);
226
226
  }
227
227
  }
228
228
 
@@ -8,6 +8,6 @@ export declare const F2: unknown;
8
8
  export declare const F3: unknown;
9
9
  declare const _default: {
10
10
  title: string;
11
- component: (props: Props) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
11
+ component: (props: Props) => React.ReactElement;
12
12
  };
13
13
  export default _default;
@@ -4,6 +4,6 @@ export declare const F1: unknown;
4
4
  export declare const F2: unknown;
5
5
  declare const _default: {
6
6
  title: string;
7
- component: (props: Props) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
7
+ component: (props: Props) => React.ReactElement;
8
8
  };
9
9
  export default _default;
@@ -1,5 +1,3 @@
1
- /// <reference path="../../../types/aphrodite.d.ts" />
2
- /// <reference types="react" />
3
1
  import type { TestHarnessConfigs } from "../types";
4
2
  /**
5
3
  * NOTE: We do not type `DefaultAdapters` with `Adapters` here because we want
@@ -12,12 +10,9 @@ import type { TestHarnessConfigs } from "../types";
12
10
  export declare const DefaultAdapters: {
13
11
  readonly boundary: import("../types").TestHarnessAdapter<(error: Error | null | undefined, errorInfo: {
14
12
  componentStack: string;
15
- }) => import("react").ReactNode>;
13
+ }) => React.ReactNode>;
16
14
  readonly css: import("../types").TestHarnessAdapter<string | string[] | import("aphrodite").CSSProperties | {
17
- /**
18
- * The default adapters provided by Wonder Blocks.
19
- */
20
- classes: string[];
15
+ classes: Array<string>;
21
16
  style: import("aphrodite").CSSProperties;
22
17
  }>;
23
18
  readonly portal: import("../types").TestHarnessAdapter<string>;
@@ -25,14 +20,14 @@ export declare const DefaultAdapters: {
25
20
  initialEntries: import("history").LocationDescriptor<unknown>[] | undefined;
26
21
  initialIndex?: number | undefined;
27
22
  getUserConfirmation?: ((message: string, callback: (ok: boolean) => void) => void) | undefined;
28
- path?: string | undefined;
23
+ path?: string;
29
24
  } | {
30
- location: import("history").LocationDescriptor<unknown>;
25
+ location: import("history").LocationDescriptor;
31
26
  forceStatic: true;
32
- path?: string | undefined;
27
+ path?: string;
33
28
  } | {
34
- location: import("history").LocationDescriptor<unknown>;
35
- path?: string | undefined;
29
+ location: import("history").LocationDescriptor;
30
+ path?: string;
36
31
  }>>;
37
32
  };
38
33
  /**
@@ -14,4 +14,4 @@ import type { TestHarnessAdapters, TestHarnessConfigs } from "./types";
14
14
  * configs?: $Shape<TestHarnessConfigs<TAdapters>>,
15
15
  * ) => React.AbstractComponent<any, any>} A test harness.
16
16
  */
17
- export declare const makeHookHarness: <TAdapters extends TestHarnessAdapters>(adapters: TAdapters, defaultConfigs: TestHarnessConfigs<TAdapters>) => (configs?: Partial<TestHarnessConfigs<TAdapters>> | undefined) => React.ForwardRefExoticComponent<any>;
17
+ export declare const makeHookHarness: <TAdapters extends TestHarnessAdapters>(adapters: TAdapters, defaultConfigs: TestHarnessConfigs<TAdapters>) => ((configs?: Partial<TestHarnessConfigs<TAdapters>>) => React.ForwardRefExoticComponent<any>);
@@ -12,4 +12,4 @@ import type { TestHarnessAdapters, TestHarnessConfigs } from "./types";
12
12
  * the adapters.
13
13
  * @returns A test harness.
14
14
  */
15
- export declare const makeTestHarness: <TAdapters extends TestHarnessAdapters>(adapters: TAdapters, defaultConfigs: TestHarnessConfigs<TAdapters>) => <TProps extends object>(Component: React.ComponentType<TProps>, configs?: Partial<TestHarnessConfigs<TAdapters>> | undefined) => React.ForwardRefExoticComponent<React.PropsWithoutRef<TProps> & React.RefAttributes<unknown>>;
15
+ export declare const makeTestHarness: <TAdapters extends TestHarnessAdapters>(adapters: TAdapters, defaultConfigs: TestHarnessConfigs<TAdapters>) => (<TProps extends object>(Component: React.ComponentType<TProps>, configs?: Partial<TestHarnessConfigs<TAdapters>>) => React.ForwardRefExoticComponent<React.PropsWithoutRef<TProps> & React.RefAttributes<unknown>>);
@@ -1,5 +1,3 @@
1
- /// <reference path="../../types/aphrodite.d.ts" />
2
- /// <reference types="react" />
3
1
  /**
4
2
  * Wrap a component with a test harness using Wonder Blocks default adapters.
5
3
  *
@@ -12,9 +10,9 @@
12
10
  export declare const testHarness: <TProps extends object>(Component: import("react").ComponentType<TProps>, configs?: Partial<import("./types").TestHarnessConfigs<{
13
11
  readonly boundary: import("./types").TestHarnessAdapter<(error: Error | null | undefined, errorInfo: {
14
12
  componentStack: string;
15
- }) => import("react").ReactNode>;
13
+ }) => React.ReactNode>;
16
14
  readonly css: import("./types").TestHarnessAdapter<string | string[] | import("aphrodite").CSSProperties | {
17
- classes: string[];
15
+ classes: Array<string>;
18
16
  style: import("aphrodite").CSSProperties;
19
17
  }>;
20
18
  readonly portal: import("./types").TestHarnessAdapter<string>;
@@ -22,13 +20,13 @@ export declare const testHarness: <TProps extends object>(Component: import("rea
22
20
  initialEntries: import("history").LocationDescriptor<unknown>[] | undefined;
23
21
  initialIndex?: number | undefined;
24
22
  getUserConfirmation?: ((message: string, callback: (ok: boolean) => void) => void) | undefined;
25
- path?: string | undefined;
23
+ path?: string;
26
24
  } | {
27
- location: import("history").LocationDescriptor<unknown>;
25
+ location: import("history").LocationDescriptor;
28
26
  forceStatic: true;
29
- path?: string | undefined;
27
+ path?: string;
30
28
  } | {
31
- location: import("history").LocationDescriptor<unknown>;
32
- path?: string | undefined;
29
+ location: import("history").LocationDescriptor;
30
+ path?: string;
33
31
  }>>;
34
32
  }>> | undefined) => import("react").ForwardRefExoticComponent<import("react").PropsWithoutRef<TProps> & import("react").RefAttributes<unknown>>;
package/dist/index.js CHANGED
@@ -1,17 +1,12 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var React = require('react');
6
4
  var addonActions = require('@storybook/addon-actions');
7
5
  var reactRouterDom = require('react-router-dom');
8
6
  var _extends = require('@babel/runtime/helpers/extends');
9
7
  var ReactDOMServer = require('react-dom/server');
10
8
 
11
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
-
13
- function _interopNamespace(e) {
14
- if (e && e.__esModule) return e;
9
+ function _interopNamespaceDefault(e) {
15
10
  var n = Object.create(null);
16
11
  if (e) {
17
12
  Object.keys(e).forEach(function (k) {
@@ -24,13 +19,12 @@ function _interopNamespace(e) {
24
19
  }
25
20
  });
26
21
  }
27
- n["default"] = e;
22
+ n.default = e;
28
23
  return Object.freeze(n);
29
24
  }
30
25
 
31
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
32
- var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
33
- var ReactDOMServer__namespace = /*#__PURE__*/_interopNamespace(ReactDOMServer);
26
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
27
+ var ReactDOMServer__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOMServer);
34
28
 
35
29
  const fixtures = Component => {
36
30
  const templateMap = new WeakMap();
@@ -221,7 +215,7 @@ class SettleSignal extends EventTarget {
221
215
  constructor(setSettleFn = null) {
222
216
  super();
223
217
  this._settled = false;
224
- setSettleFn == null ? void 0 : setSettleFn(() => {
218
+ setSettleFn == null || setSettleFn(() => {
225
219
  if (this._settled) {
226
220
  throw new Error("SettleSignal already settled");
227
221
  }
@@ -241,8 +235,8 @@ class SettleSignal extends EventTarget {
241
235
 
242
236
  class SettleController {
243
237
  constructor() {
244
- this._settleFn = void 0;
245
- this._signal = void 0;
238
+ this._settleFn = undefined;
239
+ this._signal = undefined;
246
240
  this._signal = new SettleSignal(settleFn => this._settleFn = settleFn);
247
241
  }
248
242
  get signal() {
@@ -250,7 +244,7 @@ class SettleController {
250
244
  }
251
245
  settle() {
252
246
  var _this$_settleFn;
253
- (_this$_settleFn = this._settleFn) == null ? void 0 : _this$_settleFn.call(this);
247
+ (_this$_settleFn = this._settleFn) == null || _this$_settleFn.call(this);
254
248
  }
255
249
  }
256
250
 
@@ -432,11 +426,11 @@ const Adapt = ({
432
426
 
433
427
  const makeTestHarness = (adapters, defaultConfigs) => {
434
428
  return (Component, configs) => {
435
- const fullConfig = _extends__default["default"]({}, defaultConfigs, configs);
429
+ const fullConfig = _extends({}, defaultConfigs, configs);
436
430
  const harnessedComponent = React__namespace.forwardRef((props, ref) => React__namespace.createElement(Adapt, {
437
431
  adapters: adapters,
438
432
  configs: fullConfig
439
- }, React__namespace.createElement(Component, _extends__default["default"]({}, props, {
433
+ }, React__namespace.createElement(Component, _extends({}, props, {
440
434
  ref: ref
441
435
  }))));
442
436
  harnessedComponent.displayName = `testHarness(${Component.displayName || Component.name || "Component"})`;
@@ -29,5 +29,5 @@ type RenderHookStaticResult<Result> = {
29
29
  * any effects are run, mimicking a server-side rendered result or initial
30
30
  * client-side render.
31
31
  */
32
- export declare const renderHookStatic: <Result, Props>(render: (initialProps?: Props | undefined) => Result, { wrapper, initialProps }?: Options<Props>) => RenderHookStaticResult<Result>;
32
+ export declare const renderHookStatic: <Result, Props>(render: (initialProps?: Props) => Result, { wrapper, initialProps }?: Options<Props>) => RenderHookStaticResult<Result>;
33
33
  export {};
@@ -45,7 +45,7 @@ export declare const RespondWith: Readonly<{
45
45
  /**
46
46
  * Response with GraphQL data JSON body and status code 200.
47
47
  */
48
- graphQLData: <TData_1 extends Record<any, any>>(data: TData_1, signal?: SettleSignal | null) => MockResponse<GraphQLJson<TData_1>>;
48
+ graphQLData: <TData extends Record<any, any>>(data: TData, signal?: SettleSignal | null) => MockResponse<GraphQLJson<TData>>;
49
49
  /**
50
50
  * Response with body that will not parse as JSON and status code 200.
51
51
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-testing-core",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,15 +9,12 @@
9
9
  "main": "dist/index.js",
10
10
  "module": "dist/es/index.js",
11
11
  "types": "dist/index.d.ts",
12
- "scripts": {
13
- "test": "echo \"Error: no test specified\" && exit 1"
14
- },
15
12
  "dependencies": {
16
- "@babel/runtime": "^7.18.6"
13
+ "@babel/runtime": "^7.24.5"
17
14
  },
18
15
  "peerDependencies": {
19
- "@khanacademy/wonder-stuff-core": "^1.2.2",
20
- "@storybook/addon-actions": "^8.2.1",
16
+ "@khanacademy/wonder-stuff-core": "^1.5.4",
17
+ "@storybook/addon-actions": "^8.5.2",
21
18
  "aphrodite": "^1.2.5",
22
19
  "node-fetch": "^2.6.7",
23
20
  "react": "18.2.0",
@@ -25,9 +22,12 @@
25
22
  "react-router-dom": "5.3.4"
26
23
  },
27
24
  "devDependencies": {
28
- "@khanacademy/wb-dev-build-settings": "^2.0.0",
29
- "@khanacademy/wonder-stuff-testing": "^3.0.1"
25
+ "@khanacademy/wonder-stuff-testing": "^3.0.1",
26
+ "@khanacademy/wb-dev-build-settings": "2.1.0"
30
27
  },
31
28
  "author": "",
32
- "license": "MIT"
29
+ "license": "MIT",
30
+ "scripts": {
31
+ "test": "echo \"Error: no test specified\" && exit 1"
32
+ }
33
33
  }