From 67b2e5d33ff18d70c879966c2a91f0c3e143fabe Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Sun, 30 Jul 2023 13:30:24 +0200 Subject: [PATCH] Test the plan detail with TEST_NUTRITIONAL_PLAN_1 That one has more diary entries, so the different charts and tables will be rendered as well --- .../Nutrition/components/PlanDetail.test.tsx | 12 ++++++------ src/tests/nutritionTestdata.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/Nutrition/components/PlanDetail.test.tsx b/src/components/Nutrition/components/PlanDetail.test.tsx index 7141de7f..624d8da1 100644 --- a/src/components/Nutrition/components/PlanDetail.test.tsx +++ b/src/components/Nutrition/components/PlanDetail.test.tsx @@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/react'; import { PlanDetail } from "components/Nutrition/components/PlanDetail"; import { useFetchNutritionalPlanQuery } from "components/Nutrition/queries"; import { MemoryRouter, Route, Routes } from "react-router"; -import { TEST_NUTRITIONAL_PLAN_2 } from "tests/nutritionTestdata"; +import { TEST_NUTRITIONAL_PLAN_1 } from "tests/nutritionTestdata"; jest.mock("components/Nutrition/queries"); jest.useFakeTimers(); @@ -12,12 +12,12 @@ const { ResizeObserver } = window; const queryClient = new QueryClient(); describe("Test the PlanDetail component", () => { - + beforeEach(() => { // @ts-ignore useFetchNutritionalPlanQuery.mockImplementation(() => ({ isSuccess: true, - data: TEST_NUTRITIONAL_PLAN_2 + data: TEST_NUTRITIONAL_PLAN_1 })); // @ts-ignore @@ -52,8 +52,8 @@ describe("Test the PlanDetail component", () => { // Assert expect(useFetchNutritionalPlanQuery).toHaveBeenCalled(); - expect(screen.getByText('Bulking till we puke')).toBeInTheDocument(); - expect(screen.getByText('Cake time')).toBeInTheDocument(); - expect(screen.getByText('Time to visit McDonalds')).toBeInTheDocument(); + expect(screen.getByText('Second breakfast')).toBeInTheDocument(); + expect(screen.getByText('evening snack')).toBeInTheDocument(); + expect(screen.getByText('breakfast')).toBeInTheDocument(); }); }); diff --git a/src/tests/nutritionTestdata.ts b/src/tests/nutritionTestdata.ts index 497219c6..cc702c06 100644 --- a/src/tests/nutritionTestdata.ts +++ b/src/tests/nutritionTestdata.ts @@ -51,7 +51,7 @@ export const TEST_MEAL_ITEM_1 = new MealItem( TEST_INGREDIENT_1 ); export const TEST_MEAL_ITEM_2 = new MealItem( - 42, + 43, 102, null, 220,