Skip to content

Commit 953977b

Browse files
author
scottrippey
committed
test: moved react-17 test into src
1 parent 63c9223 commit 953977b

File tree

5 files changed

+97
-22
lines changed

5 files changed

+97
-22
lines changed

src/useEvent.test-react-17.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Run all the other tests:
2+
import "./useEvent.test";
3+
4+
// Just to make sure our overrides are working:
5+
import React from "react";
6+
it(`we're testing React 17`, async () => {
7+
expect(React.version).toMatchInlineSnapshot(`"17.0.2"`);
8+
});

test/react-17/jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ module.exports = {
22
...require("../../jest.config"),
33
rootDir: ".",
44
moduleNameMapper: {
5-
// Ensure we "lock" the React version for these tests:
5+
// Ensure we "lock" the React version to v17 for these tests:
66
"^react$": "<rootDir>/node_modules/react",
7-
// Use react-hooks instead:
7+
// Use react-hooks instead (we have a tiny bit of interop code to ensure the tests still work)
88
"^@testing-library/react$": "<rootDir>/node_modules/@testing-library/react-hooks",
99
},
1010
};

test/react-17/package-lock.json

Lines changed: 84 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/react-17/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"devDependencies": {
33
"@testing-library/react-hooks": "^8.0.1",
4-
"react": "^17.0.2"
4+
"react": "^17.0.2",
5+
"react-test-renderer": "^17.0.2"
56
},
67
"scripts": {
78
"test": "jest"
Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1 @@
1-
import React from "react";
2-
import { renderHook } from "@testing-library/react-hooks";
3-
4-
// import useEvent from "../../src/useEvent";
5-
6-
it(`we're testing React 17`, async () => {
7-
expect(React.version).toMatchInlineSnapshot(`"17.0.2"`);
8-
});
9-
10-
describe("useEvent", () => {
11-
it("should stuff", async () => {
12-
const res = renderHook(() => {
13-
return 5;
14-
// return React.useMemo(() => 5, []);
15-
});
16-
expect(typeof res.result.current).toEqual("function");
17-
});
18-
});
1+
import "../../src/useEvent.test-react-17";

0 commit comments

Comments
 (0)