@khanacademy/wonder-blocks-testing-core 2.0.1 → 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 +16 -7
- package/LICENSE +21 -0
- package/dist/es/index.js +4 -4
- package/dist/fixtures/fixtures.basic.stories.d.ts +1 -1
- package/dist/fixtures/fixtures.defaultwrapper.stories.d.ts +1 -1
- package/dist/harness/adapters/adapters.d.ts +7 -12
- package/dist/harness/make-hook-harness.d.ts +1 -1
- package/dist/harness/make-test-harness.d.ts +1 -1
- package/dist/harness/test-harness.d.ts +7 -9
- package/dist/index.js +10 -16
- package/dist/render-hook-static.d.ts +1 -1
- package/dist/respond-with.d.ts +1 -1
- package/package.json +10 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,38 +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
|
+
|
|
3
12
|
## 2.0.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
6
15
|
|
|
7
|
-
-
|
|
16
|
+
- 11a0f5c6: No functional changes. Adding prepublishOnly script.
|
|
8
17
|
|
|
9
18
|
## 2.0.0
|
|
10
19
|
|
|
11
20
|
### Major Changes
|
|
12
21
|
|
|
13
|
-
-
|
|
22
|
+
- e6abdd17: Upgrade to React 18
|
|
14
23
|
|
|
15
24
|
## 1.1.0
|
|
16
25
|
|
|
17
26
|
### Minor Changes
|
|
18
27
|
|
|
19
|
-
-
|
|
28
|
+
- 16565a85: Add support for hard fails to the request mocking features
|
|
20
29
|
|
|
21
30
|
## 1.0.2
|
|
22
31
|
|
|
23
32
|
### Patch Changes
|
|
24
33
|
|
|
25
|
-
-
|
|
34
|
+
- 02a1b298: Make sure we don't package tsconfig and tsbuildinfo files
|
|
26
35
|
|
|
27
36
|
## 1.0.1
|
|
28
37
|
|
|
29
38
|
### Patch Changes
|
|
30
39
|
|
|
31
|
-
-
|
|
32
|
-
-
|
|
40
|
+
- c954464a: Fix how react-dom/server is imported in Wonder Blocks Testing Core
|
|
41
|
+
- 559e82d5: Update to build tooling, generating smaller output
|
|
33
42
|
|
|
34
43
|
## 1.0.0
|
|
35
44
|
|
|
36
45
|
### Major Changes
|
|
37
46
|
|
|
38
|
-
-
|
|
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
|
|
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 =
|
|
217
|
-
this._signal =
|
|
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
|
|
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
|
|
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
|
|
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
|
-
}) =>
|
|
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
|
|
23
|
+
path?: string;
|
|
29
24
|
} | {
|
|
30
|
-
location: import("history").LocationDescriptor
|
|
25
|
+
location: import("history").LocationDescriptor;
|
|
31
26
|
forceStatic: true;
|
|
32
|
-
path?: string
|
|
27
|
+
path?: string;
|
|
33
28
|
} | {
|
|
34
|
-
location: import("history").LocationDescriptor
|
|
35
|
-
path?: string
|
|
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>>
|
|
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>>
|
|
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
|
-
}) =>
|
|
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
|
|
23
|
+
path?: string;
|
|
26
24
|
} | {
|
|
27
|
-
location: import("history").LocationDescriptor
|
|
25
|
+
location: import("history").LocationDescriptor;
|
|
28
26
|
forceStatic: true;
|
|
29
|
-
path?: string
|
|
27
|
+
path?: string;
|
|
30
28
|
} | {
|
|
31
|
-
location: import("history").LocationDescriptor
|
|
32
|
-
path?: string
|
|
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
|
|
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
|
|
22
|
+
n.default = e;
|
|
28
23
|
return Object.freeze(n);
|
|
29
24
|
}
|
|
30
25
|
|
|
31
|
-
var React__namespace = /*#__PURE__*/
|
|
32
|
-
var
|
|
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
|
|
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 =
|
|
245
|
-
this._signal =
|
|
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
|
|
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 =
|
|
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,
|
|
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
|
|
32
|
+
export declare const renderHookStatic: <Result, Props>(render: (initialProps?: Props) => Result, { wrapper, initialProps }?: Options<Props>) => RenderHookStaticResult<Result>;
|
|
33
33
|
export {};
|
package/dist/respond-with.d.ts
CHANGED
|
@@ -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: <
|
|
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
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,16 +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
|
-
"prepublishOnly": "../../utils/publish/package-pre-publish-check.sh"
|
|
15
|
-
},
|
|
16
12
|
"dependencies": {
|
|
17
|
-
"@babel/runtime": "^7.
|
|
13
|
+
"@babel/runtime": "^7.24.5"
|
|
18
14
|
},
|
|
19
15
|
"peerDependencies": {
|
|
20
|
-
"@khanacademy/wonder-stuff-core": "^1.
|
|
21
|
-
"@storybook/addon-actions": "^8.2
|
|
16
|
+
"@khanacademy/wonder-stuff-core": "^1.5.4",
|
|
17
|
+
"@storybook/addon-actions": "^8.5.2",
|
|
22
18
|
"aphrodite": "^1.2.5",
|
|
23
19
|
"node-fetch": "^2.6.7",
|
|
24
20
|
"react": "18.2.0",
|
|
@@ -26,9 +22,12 @@
|
|
|
26
22
|
"react-router-dom": "5.3.4"
|
|
27
23
|
},
|
|
28
24
|
"devDependencies": {
|
|
29
|
-
"@khanacademy/
|
|
30
|
-
"@khanacademy/
|
|
25
|
+
"@khanacademy/wonder-stuff-testing": "^3.0.1",
|
|
26
|
+
"@khanacademy/wb-dev-build-settings": "2.1.0"
|
|
31
27
|
},
|
|
32
28
|
"author": "",
|
|
33
|
-
"license": "MIT"
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
32
|
+
}
|
|
34
33
|
}
|