diff --git a/hackathon_site/dashboard/frontend/src/components/orders/OrdersCount/OrdersCount.test.tsx b/hackathon_site/dashboard/frontend/src/components/orders/OrdersCount/OrdersCount.test.tsx
index d87a361..942a81a 100644
--- a/hackathon_site/dashboard/frontend/src/components/orders/OrdersCount/OrdersCount.test.tsx
+++ b/hackathon_site/dashboard/frontend/src/components/orders/OrdersCount/OrdersCount.test.tsx
@@ -1,11 +1,25 @@
import React from "react";
import { render } from "@testing-library/react";
-import OrdersFilter from "./OrdersCount";
+import { makeStoreWithEntities } from "../../../testing/utils";
+import { mockHardware, mockPendingOrders } from "../../../testing/mockData";
+import { Provider } from "react-redux";
+import OrdersCount from "./OrdersCount";
describe("", () => {
+ const store = makeStoreWithEntities({
+ hardware: mockHardware,
+ allOrders: mockPendingOrders,
+ });
+
it("Has necessary component elements", async () => {
- const { getByText, getByTestId } = render();
+ const { getByText, getByTestId } = render(
+
+ {" "}
+ {" "}
+
+ );
expect(getByTestId("refreshOrders")).toBeInTheDocument();
- expect(getByText("2 results")).toBeInTheDocument();
+ const expectedCount = mockPendingOrders.length;
+ expect(getByText(`${expectedCount} results`)).toBeInTheDocument();
});
});
diff --git a/hackathon_site/dashboard/frontend/src/components/orders/OrdersCount/OrdersCount.tsx b/hackathon_site/dashboard/frontend/src/components/orders/OrdersCount/OrdersCount.tsx
index 8f4ba2d..dbc609b 100644
--- a/hackathon_site/dashboard/frontend/src/components/orders/OrdersCount/OrdersCount.tsx
+++ b/hackathon_site/dashboard/frontend/src/components/orders/OrdersCount/OrdersCount.tsx
@@ -3,11 +3,14 @@ import { IconButton, Typography } from "@material-ui/core";
import RefreshIcon from "@material-ui/icons/Refresh";
import styles from "pages/Orders/Orders.module.scss";
import { FormikValues } from "formik";
+import { useSelector } from "react-redux";
+import { adminOrderTotalSelector } from "../../../slices/order/adminOrderSlice";
const OrdersCount = ({ refreshOrders }: FormikValues) => {
+ const orderQuantity = useSelector(adminOrderTotalSelector);
return (
- 2 results
+ {orderQuantity} results
adminOrderSlice.numStatuses
);
+export const adminOrderTotalSelector = createSelector(
+ [adminOrderSelectors.selectAll],
+ (orderItems) => orderItems.reduce((accum) => accum + 1, 0)
+);
+
export const { setFilters, clearFilters } = actions;