Skip to content

Commit

Permalink
test: replace enzyme test code with @testing-library/react. (#471)
Browse files Browse the repository at this point in the history
* Update test case. Replace enzyme test code with @testing-library/react.

Update test cases in `tests/index.spec.tsx` to use `@testing-library/react` instead of `enzyme`.

* Replace `enzyme` imports with `@testing-library/react` imports.
* Update test cases to use `render`, `fireEvent`, and other utilities from `@testing-library/react`.
* Remove `mount` and `ReactWrapper` imports.
* Change code `props.style` with `toHaveStyle({ key: value })` style.
* Change `style.display` check to be `toHaveStyle("display: block")` or `display: none`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/react-component/dialog?shareId=XXXX-XXXX-XXXX-XXXX).

* test: fix part

* test: fix lint

* test: fix test case

* chore: adjust package.json
  • Loading branch information
zombieJ authored Jan 10, 2025
1 parent 7b7a302 commit ffa313a
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 238 deletions.
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
setupFiles: ["./tests/setup.js"],
setupFilesAfterEnv: ["./tests/setupFilesAfterEnv.ts"],
snapshotSerializers: [require.resolve("enzyme-to-json/serializer")],
};
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
"devDependencies": {
"@rc-component/father-plugin": "^2.0.1",
"@testing-library/jest-dom": "^6.1.6",
"@testing-library/react": "^12.0.0",
"@types/enzyme": "^3.10.7",
"@testing-library/react": "^13.0.0",
"@types/jest": "^29.4.0",
"@types/keyv": "3.1.4",
"@types/react": "^18.0.24",
Expand All @@ -69,9 +68,6 @@
"cheerio": "1.0.0-rc.12",
"cross-env": "^7.0.0",
"dumi": "^2.1.3",
"enzyme": "^3.1.1",
"enzyme-adapter-react-16": "^1.0.1",
"enzyme-to-json": "^3.1.2",
"eslint": "^7.1.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-react": "^7.20.6",
Expand All @@ -86,13 +82,13 @@
"rc-drawer": "^7.0.0",
"rc-select": "^14.11.0",
"rc-test": "^7.0.14",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-draggable": "^4.4.3",
"typescript": "^5.4.3"
},
"peerDependencies": {
"react": ">=16.9.0",
"react-dom": ">=16.9.0"
"react": ">=18.0.0",
"react-dom": ">=18.0.0"
}
}
Loading

0 comments on commit ffa313a

Please sign in to comment.