@khanacademy/wonder-blocks-testing 7.1.5 → 7.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +3 -3
- package/src/harness/adapters/__tests__/data.test.js +26 -26
- package/dist/index.js +0 -1285
- package/dist/index.js.flow +0 -2
- package/docs.md +0 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-testing",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.6",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime": "^7.18.6",
|
|
17
|
-
"@khanacademy/wonder-blocks-data": "^10.0.
|
|
17
|
+
"@khanacademy/wonder-blocks-data": "^10.0.2"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@khanacademy/wonder-stuff-core": "^0.1.2",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react-router-dom": "5.3.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"wb-dev-build-settings": "^0.
|
|
29
|
+
"wb-dev-build-settings": "^0.5.0"
|
|
30
30
|
},
|
|
31
31
|
"author": "",
|
|
32
32
|
"license": "MIT"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
4
|
-
import "
|
|
3
|
+
import {render, screen, waitFor} from "@testing-library/react";
|
|
4
|
+
import {useCachedEffect} from "@khanacademy/wonder-blocks-data";
|
|
5
5
|
import * as Data from "../data.js";
|
|
6
6
|
|
|
7
7
|
describe("WonderBlocksData.adapter", () => {
|
|
@@ -10,57 +10,57 @@ describe("WonderBlocksData.adapter", () => {
|
|
|
10
10
|
const children = <div>CONTENT</div>;
|
|
11
11
|
|
|
12
12
|
// Act
|
|
13
|
-
|
|
14
|
-
includeDefaultTestHarness: false,
|
|
15
|
-
});
|
|
13
|
+
render(Data.adapter(children, []));
|
|
16
14
|
|
|
17
15
|
// Assert
|
|
18
|
-
expect(
|
|
16
|
+
expect(screen.getByText("CONTENT")).toBeInTheDocument();
|
|
19
17
|
});
|
|
20
18
|
|
|
21
|
-
it("should
|
|
19
|
+
it("should support request interception via configured dataIntercepts", async () => {
|
|
22
20
|
// Arrange
|
|
23
|
-
|
|
21
|
+
|
|
22
|
+
const TestFixture = () => {
|
|
23
|
+
const [result] = useCachedEffect("ID", jest.fn());
|
|
24
|
+
|
|
25
|
+
return <div>CONTENT: {result?.data}</div>;
|
|
26
|
+
};
|
|
24
27
|
|
|
25
28
|
// Act
|
|
26
|
-
const
|
|
27
|
-
Data.adapter(
|
|
29
|
+
const {container} = render(
|
|
30
|
+
Data.adapter(<TestFixture />, () =>
|
|
28
31
|
Promise.resolve(("INTERCEPTED!": any)),
|
|
29
32
|
),
|
|
30
|
-
{
|
|
31
|
-
includeDefaultTestHarness: false,
|
|
32
|
-
},
|
|
33
33
|
);
|
|
34
34
|
|
|
35
35
|
// Assert
|
|
36
|
-
expect(
|
|
36
|
+
await waitFor(() => expect(container).toContainHTML("INTERCEPTED!"));
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
it("should render like we expect", () => {
|
|
40
40
|
// Snapshot test is handy to visualize what's going on and help debug
|
|
41
41
|
// test failures of the other cases. The other cases assert specifics.
|
|
42
42
|
// Arrange
|
|
43
|
-
const
|
|
43
|
+
const TestFixture = () => {
|
|
44
|
+
const [result] = useCachedEffect("ID", jest.fn());
|
|
45
|
+
|
|
46
|
+
return <div>CONTENT:{result?.data}</div>;
|
|
47
|
+
};
|
|
44
48
|
|
|
45
49
|
// Act
|
|
46
|
-
const
|
|
47
|
-
Data.adapter(
|
|
50
|
+
const {container} = render(
|
|
51
|
+
Data.adapter(<TestFixture />, () =>
|
|
48
52
|
Promise.resolve(("INTERCEPTED!": any)),
|
|
49
53
|
),
|
|
50
|
-
{
|
|
51
|
-
includeDefaultTestHarness: false,
|
|
52
|
-
},
|
|
53
54
|
);
|
|
54
55
|
|
|
55
56
|
// Assert
|
|
56
|
-
expect(
|
|
57
|
-
<
|
|
58
|
-
interceptor={[Function]}
|
|
59
|
-
>
|
|
57
|
+
expect(container).toMatchInlineSnapshot(`
|
|
58
|
+
<div>
|
|
60
59
|
<div>
|
|
61
|
-
CONTENT
|
|
60
|
+
CONTENT:
|
|
61
|
+
INTERCEPTED!
|
|
62
62
|
</div>
|
|
63
|
-
</
|
|
63
|
+
</div>
|
|
64
64
|
`);
|
|
65
65
|
});
|
|
66
66
|
});
|