@khanacademy/wonder-blocks-testing 7.1.4 → 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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @khanacademy/wonder-blocks-testing
2
2
 
3
+ ## 7.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - @khanacademy/wonder-blocks-data@10.0.2
8
+
9
+ ## 7.1.5
10
+
11
+ ### Patch Changes
12
+
13
+ - @khanacademy/wonder-blocks-data@10.0.1
14
+
3
15
  ## 7.1.4
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-testing",
3
- "version": "7.1.4",
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.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.4.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 {mount} from "enzyme"; // eslint-disable-line no-restricted-imports
4
- import "jest-enzyme";
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
- const wrapper = mount(Data.adapter(children, []), {
14
- includeDefaultTestHarness: false,
15
- });
13
+ render(Data.adapter(children, []));
16
14
 
17
15
  // Assert
18
- expect(wrapper).toHaveHTML("<div>CONTENT</div>");
16
+ expect(screen.getByText("CONTENT")).toBeInTheDocument();
19
17
  });
20
18
 
21
- it("should render children within InterceptRequests when dataIntercepts configured", () => {
19
+ it("should support request interception via configured dataIntercepts", async () => {
22
20
  // Arrange
23
- const children = <div>CONTENT</div>;
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 wrapper = mount(
27
- Data.adapter(children, () =>
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(wrapper).toContainMatchingElement("InterceptRequests");
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 children = <div>CONTENT</div>;
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 wrapper = mount(
47
- Data.adapter(children, () =>
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(wrapper).toMatchInlineSnapshot(`
57
- <InterceptRequests
58
- interceptor={[Function]}
59
- >
57
+ expect(container).toMatchInlineSnapshot(`
58
+ <div>
60
59
  <div>
61
- CONTENT
60
+ CONTENT:
61
+ INTERCEPTED!
62
62
  </div>
63
- </InterceptRequests>
63
+ </div>
64
64
  `);
65
65
  });
66
66
  });