Skip to content

Commit

Permalink
TEST - Test Suite updated
Browse files Browse the repository at this point in the history
  • Loading branch information
slytherin20 committed Dec 11, 2023
1 parent a4d8609 commit 5fba7cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Components/DishCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export default function DishCard({ dish, restaurantInfo, user }) {
<button
onClick={toggleDetails}
className="p-1 border border-red-700 rounded-md text-black text-xs"
data-testid="details"
>
Details {">>"}
</button>
Expand Down
8 changes: 5 additions & 3 deletions src/__tests__/dishCard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import store from "../Store/store";
import { fireEvent, render } from "@testing-library/react";
import DishCard from "../Components/DishCard";
import { dishWithoutCustom } from "../Dummy/DishNoCustomization.js";
import "@testing-library/jest-dom";

jest.mock("firebase/auth", () => {
return {
getAuth: jest.fn().mockReturnValue({
Expand All @@ -29,16 +31,16 @@ describe("Checking Dish Card Layout", () => {
const vegNonVegDesc = item.getByTestId("food-pref-name");
const name = item.getByTestId("dish-name");
const price = item.getByTestId("dish-price");
const desc = item.getByTestId("dish-desc");
expect(dish.children.length).toBe(3);
const desc = item.getByTestId("details");
expect(dish.children.length).toBe(2);
expect(info.children.length).toBe(4);
expect(vegNonVeg.src).toMatch(
/^(https?:\/\/)(i\.imgur\.com\/lEMNtv0\.png|i\.imgur\.com\/qmye33X\.png)$/
);
expect(vegNonVegDesc.innerHTML).toMatch(/^(VEG|NON\\-VEG)$/);
expect(name.innerHTML.length).toBeGreaterThan(0);
expect(Number(price.innerHTML.slice(1))).toBeGreaterThan(0);
expect(desc.innerHTML.length).toBeGreaterThan(0);
expect(desc).toBeInTheDocument();
});
});

Expand Down

0 comments on commit 5fba7cc

Please sign in to comment.