Skip to content

Commit

Permalink
test: switch to @testing-library/react
Browse files Browse the repository at this point in the history
  • Loading branch information
zyc9012 committed May 7, 2022
1 parent fac193e commit b048871
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 287 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@
"@storybook/addon-links": "^6.4.19",
"@storybook/react": "^6.4.19",
"@storybook/testing-library": "^0.0.9",
"@types/enzyme": "^3.10.11",
"@testing-library/react": "^12.1.5",
"@types/jest": "^27.4.1",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
"babel-jest": "^27.5.1",
"babel-loader": "^8.2.3",
"enzyme": "^3.11.0",
"eslint": "^8.10.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
Expand Down
11 changes: 6 additions & 5 deletions packages/react/test/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { mount } from "enzyme";
import { render } from "@testing-library/react";
import React from "react";
import Workbook from "../src/components/Workbook";
import { waitForComponentToPaint } from "../../../tests/util";

describe("Worksheet", () => {
it("should render", async () => {
const wrapper = mount(<Workbook data={[{ name: "Sheet1" }]} />);
await waitForComponentToPaint(wrapper);
expect(wrapper.exists(".fortune-sheet-container")).toBeTruthy();
const { queryByText, container } = render(
<Workbook data={[{ name: "Sheet1" }]} />
);
expect(container.querySelector(".fortune-sheet-container")).toBeTruthy();
expect(queryByText("Sheet1")).toBeTruthy();
});
});
4 changes: 0 additions & 4 deletions tests/setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Enzyme from "enzyme";
import Adapter from "@wojtekmaj/enzyme-adapter-react-17";
import "jest-canvas-mock";

import React from "react";
Expand All @@ -13,8 +11,6 @@ jest.mock("react", () => ({

jest.setTimeout(60000);

Enzyme.configure({ adapter: new Adapter() });

Object.defineProperty(window, "open", {
value: jest.fn,
});
Expand Down
12 changes: 0 additions & 12 deletions tests/util.ts

This file was deleted.

Loading

0 comments on commit b048871

Please sign in to comment.