Skip to content

Commit 8d47441

Browse files
committed
Add tests for node imports
1 parent 5ce1226 commit 8d47441

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
npm-debug.log
22

3-
/build/
3+
/build/node_modules/
4+
45
/docs/api/
56
/website/build/
67
node_modules/
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const expected = {
2+
BrowserRouter: expect.any(Function),
3+
Link: expect.any(Function),
4+
// from react-router
5+
Router: expect.any(Function),
6+
Route: expect.any(Function),
7+
Routes: expect.any(Function),
8+
MemoryRouter: expect.any(Function),
9+
Outlet: expect.any(Function),
10+
useRoutes: expect.any(Function),
11+
useParams: expect.any(Function),
12+
useResolvedPath: expect.any(Function),
13+
useOutlet: expect.any(Function),
14+
useOutletContext: expect.any(Function),
15+
};
16+
17+
describe("react-router-dom", () => {
18+
it("requires", () => {
19+
expect(require("react-router-dom")).toMatchObject(expected);
20+
});
21+
22+
it("imports", () => {
23+
return expect(import("react-router-dom")).resolves.toMatchObject(expected);
24+
});
25+
});

build/__tests__/react-router-test.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const expected = {
2+
Router: expect.any(Function),
3+
Route: expect.any(Function),
4+
Routes: expect.any(Function),
5+
MemoryRouter: expect.any(Function),
6+
Outlet: expect.any(Function),
7+
useRoutes: expect.any(Function),
8+
useParams: expect.any(Function),
9+
useResolvedPath: expect.any(Function),
10+
useOutlet: expect.any(Function),
11+
useOutletContext: expect.any(Function),
12+
};
13+
14+
describe("react-router", () => {
15+
it("requires", () => {
16+
expect(require("react-router")).toMatchObject(expected);
17+
});
18+
19+
it("imports", () => {
20+
return expect(import("react-router")).resolves.toMatchObject(expected);
21+
});
22+
});

build/jest.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
testMatch: ["**/__tests__/*-test.[jt]s?(x)"]
3+
};

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
},
7474
"jest": {
7575
"projects": [
76-
"<rootDir>/packages/*"
76+
"<rootDir>/packages/*",
77+
"<rootDir>/build"
7778
]
7879
},
7980
"filesize": {

0 commit comments

Comments
 (0)