Skip to content

Commit

Permalink
add jest test
Browse files Browse the repository at this point in the history
  • Loading branch information
mDandini committed Feb 28, 2023
1 parent 59aaac6 commit 990b792
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"scripts": {
"start:web": "react-scripts start",
"build:web": "react-scripts build",
"test": "react-scripts test",
"test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!calcite-components-react)/\"",
"eject": "react-scripts eject",
"start:server": "cross-env NODE_ENV=development nodemon server/main.js",
"start:prod-server": "cross-env NODE_ENV=production nodemon server/main.js",
Expand Down
40 changes: 34 additions & 6 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
import { render, screen } from '@testing-library/react';
import App from './App';
import { render, screen } from "@testing-library/react";
import App from "./App";

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
jest.mock("./components/MapContainer", () => {
return () => {
return <div>Map Container</div>;
};
});

jest.mock("./components/BookmarkNav", () => {
return () => {
return <div>Bookmark Nav</div>;
};
});

jest.mock("./components/InfoLookup", () => {
return () => {
return <div>Info Lookup</div>;
};
});

jest.mock("@esri/calcite-components-react", () => {
return {
CalciteShell: ({ children }) => <div>{children}</div>,
CalciteShellPanel: ({ children }) => <div>{children}</div>,
CalcitePanel: ({ children }) => <div>{children}</div>,
};
});

test("renders learn react link", () => {
const { getByText } = render(<App />);

expect(getByText("Map Container")).toBeInTheDocument();
expect(getByText("Bookmark Nav")).toBeInTheDocument();
expect(getByText("Info Lookup")).toBeInTheDocument();
});

0 comments on commit 990b792

Please sign in to comment.