From de202178145165301dfff80a8d56e156425c4e3c Mon Sep 17 00:00:00 2001 From: shmansa Date: Fri, 12 May 2023 18:30:06 -0700 Subject: [PATCH 1/2] Fixs bug #241 --- frontend/src/__tests__/Feed.test.tsx | 56 ++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 frontend/src/__tests__/Feed.test.tsx diff --git a/frontend/src/__tests__/Feed.test.tsx b/frontend/src/__tests__/Feed.test.tsx new file mode 100644 index 00000000..51bb0517 --- /dev/null +++ b/frontend/src/__tests__/Feed.test.tsx @@ -0,0 +1,56 @@ +import React from "react"; +import { render, screen } from "@testing-library/react"; +import Feed from "../Components/Feed/Feed"; + +describe("Feed component", () => { + const sortedFeedList = [ + { + id: 1, + item: "Apples", + expiry_date: "2023-05-10", + added_date: "2023-05-01", + quantity: 10, + }, + { + id: 2, + item: "Oranges", + expiry_date: "2023-05-05", + added_date: "2023-05-01", + quantity: 5, + }, + ]; + + const sortedExpiredFeedList = [ + { + id: 3, + item: "Bananas", + expiry_date: "2023-04-30", + added_date: "2023-04-01", + quantity: 0, + }, + ]; + + it("should render the correct expiring items", () => { + render(); + + const appleItem = screen.queryByText("Apples"); + const orangeItem = screen.queryByText("Oranges"); + const bananaItem = screen.queryByText("Bananas"); + + expect(appleItem).not.toBeInTheDocument(); + expect(orangeItem).not.toBeInTheDocument(); + //expect(bananaItem).not.toBeInTheDocument(); + }); + + it("should render the correct expired items", () => { + render(); + + const appleItem = screen.queryByText("Apples"); + const orangeItem = screen.queryByText("Oranges"); + const bananaItem = screen.getByText("Bananas"); + + //expect(appleItem).not.toBeInTheDocument(); + //expect(orangeItem).not.toBeInTheDocument(); + expect(bananaItem).toBeInTheDocument(); + }); +}); \ No newline at end of file From a7d318e4a2751d3ceb857efaaef598c8e40b5992 Mon Sep 17 00:00:00 2001 From: shmansa Date: Fri, 12 May 2023 19:42:31 -0700 Subject: [PATCH 2/2] Fixs bug #241 --- frontend/src/__tests__/Feed.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/__tests__/Feed.test.tsx b/frontend/src/__tests__/Feed.test.tsx index 51bb0517..1be36f93 100644 --- a/frontend/src/__tests__/Feed.test.tsx +++ b/frontend/src/__tests__/Feed.test.tsx @@ -49,8 +49,8 @@ describe("Feed component", () => { const orangeItem = screen.queryByText("Oranges"); const bananaItem = screen.getByText("Bananas"); - //expect(appleItem).not.toBeInTheDocument(); - //expect(orangeItem).not.toBeInTheDocument(); + expect(appleItem).not.toBeInTheDocument(); + expect(orangeItem).not.toBeInTheDocument(); expect(bananaItem).toBeInTheDocument(); }); }); \ No newline at end of file