diff --git a/src/components/Resources/Resources.js b/src/components/Resources/Resources.js
index 30f9f34..6516db3 100644
--- a/src/components/Resources/Resources.js
+++ b/src/components/Resources/Resources.js
@@ -15,14 +15,15 @@ return (
{
ResourcesList.map(resource =>
- {resource.name}
- {resource.body}
+
{resource.name}
+ {resource.body}
- More info
+ More info
- )}
-
+ )
+ }
+
-
+
);
}
\ No newline at end of file
diff --git a/src/components/Resources/Resources.test.js b/src/components/Resources/Resources.test.js
new file mode 100644
index 0000000..88636c1
--- /dev/null
+++ b/src/components/Resources/Resources.test.js
@@ -0,0 +1,56 @@
+import { render, screen, fireEvent } from "@testing-library/react";
+import Resources from "../Resources/Resources";
+import Toggle from "../Toggle";
+import { BrowserRouter, Router, Link } from 'react-router-dom';
+import { createMemoryHistory } from 'history';
+import data from '../data/data.json';
+
+describe("Resources", () => {
+
+ test("renders Resources Component", () => {
+ const {getByText} = render();
+ expect(screen.getByText("Open Source Programs")).toBeInTheDocument;
+ })
+ test('rendered toggle', () => {
+ const { getByTestId } = render();
+ const toggle = getByTestId("toggle");
+ expect(toggle).toBeTruthy();
+ })
+ test("resource name", () => {
+ render(
);
+ const resourceName = screen.getByTestId("name");
+ expect(resourceName).toBeInTheDocument();
+ })
+ test("resource body", () => {
+ render();
+ const resourceBody = screen.getByTestId("body");
+ expect(resourceBody).toBeInTheDocument();
+ })
+ test(" More info Link validation", async () => {
+ //check the `More info` link 12 times rendered on /resouces page
+ //check when click moreinfo link routes to corresponding page /resources/resource.id
+ //check each page has resource.name using getByText on the screen
+
+ let history = createMemoryHistory({ initialEntries: ["/resources"] });
+
+ render();
+ let moreinfoButtons = screen.getAllByText("More info");
+ for (let resource of data)
+ {
+
+
+ More info
+
+
+ expect(moreinfoButtons).toHaveLength(12)
+
+ fireEvent.click(moreinfoButtons[`${resource.id-1}`]);
+
+ expect(location.pathname).toEqual(`/resources/${resource.id}`);
+
+ await expect(screen.getByText(`${resource.name}`)).toBeInTheDocument();
+
+ }
+ })
+ screen.debug();
+})
diff --git a/src/components/Toggle.js b/src/components/Toggle.js
index 66d5df2..95db65a 100644
--- a/src/components/Toggle.js
+++ b/src/components/Toggle.js
@@ -8,7 +8,7 @@ import './Toggle.css';
export default function Toggle(){
const history = useHistory();
return (
-
+
Open Source Programs