Skip to content

Commit

Permalink
Add tests for node imports
Browse files Browse the repository at this point in the history
  • Loading branch information
perrin4869 committed Dec 13, 2021
1 parent 5ce1226 commit 8d47441
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
npm-debug.log

/build/
/build/node_modules/

/docs/api/
/website/build/
node_modules/
Expand Down
25 changes: 25 additions & 0 deletions build/__tests__/react-router-dom-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const expected = {
BrowserRouter: expect.any(Function),
Link: expect.any(Function),
// from react-router
Router: expect.any(Function),
Route: expect.any(Function),
Routes: expect.any(Function),
MemoryRouter: expect.any(Function),
Outlet: expect.any(Function),
useRoutes: expect.any(Function),
useParams: expect.any(Function),
useResolvedPath: expect.any(Function),
useOutlet: expect.any(Function),
useOutletContext: expect.any(Function),
};

describe("react-router-dom", () => {
it("requires", () => {
expect(require("react-router-dom")).toMatchObject(expected);
});

it("imports", () => {
return expect(import("react-router-dom")).resolves.toMatchObject(expected);
});
});
22 changes: 22 additions & 0 deletions build/__tests__/react-router-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const expected = {
Router: expect.any(Function),
Route: expect.any(Function),
Routes: expect.any(Function),
MemoryRouter: expect.any(Function),
Outlet: expect.any(Function),
useRoutes: expect.any(Function),
useParams: expect.any(Function),
useResolvedPath: expect.any(Function),
useOutlet: expect.any(Function),
useOutletContext: expect.any(Function),
};

describe("react-router", () => {
it("requires", () => {
expect(require("react-router")).toMatchObject(expected);
});

it("imports", () => {
return expect(import("react-router")).resolves.toMatchObject(expected);
});
});
3 changes: 3 additions & 0 deletions build/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
testMatch: ["**/__tests__/*-test.[jt]s?(x)"]
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
},
"jest": {
"projects": [
"<rootDir>/packages/*"
"<rootDir>/packages/*",
"<rootDir>/build"
]
},
"filesize": {
Expand Down

0 comments on commit 8d47441

Please sign in to comment.