Release Drafter / auto_label (push) Skipped
Backend Lint and Test / tests (sqlite) (push) Canceled after 0s
Backend Lint and Test / tests (postgres) (push) Canceled after 0s
Docker Nightly Production / Backend Server Tests (push) Canceled after 0s
Frontend Lint and Test / lint (push) Canceled after 0s
Docker Nightly Production / Frontend Tests (push) Canceled after 0s
Build Package / Build frontend and wheel (push) Canceled after 0s
Docker Nightly Production / Build Package (push) Canceled after 0s
Docker Nightly Production / Build E2E Image Cache (push) Canceled after 0s
Docker Nightly Production / Build Tagged Release (push) Canceled after 0s
Docker Nightly Production / Notify Discord (push) Canceled after 0s
CodeQL / Analyze (javascript-typescript) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
Release Drafter / draft_release (push) Canceled after 0s
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import { mount } from "@vue/test-utils";
|
|
import { describe, expect, test, vi } from "vitest";
|
|
import RecipePrintView from "./RecipePrintView.vue";
|
|
import { makeRecipe } from "~/tests/factories";
|
|
|
|
vi.mock("~/composables/api", () => ({
|
|
useStaticRoutes: () => ({ recipeImage: () => "" }),
|
|
}));
|
|
vi.mock("~/composables/use-locales", () => ({
|
|
useLocales: () => ({ locales: [{ value: "en-US" }], locale: { value: "en-US" } }),
|
|
}));
|
|
|
|
describe("RecipePrintView", () => {
|
|
test("renders ingredients and places each cooking operation with its step", () => {
|
|
const recipe = makeRecipe({
|
|
recipeIngredient: [{ referenceId: "ingredient", quantity: 100, food: { name: "flour" } }],
|
|
recipeInstructions: [
|
|
{ text: "Mix", durationSeconds: 180, cooking: { temperatureCelsius: 120, speed: "spoon" } },
|
|
{ text: "Rest" },
|
|
],
|
|
});
|
|
const wrapper = mount(RecipePrintView, {
|
|
props: { recipe },
|
|
global: {
|
|
mocks: { $globals: { icons: { primary: "", potSteam: "" } } },
|
|
stubs: {
|
|
SafeMarkdown: { props: ["source"], template: "<div>{{ source }}</div>" },
|
|
SafeInlineHtml: { props: ["html"], template: "<span>{{ html }}</span>" },
|
|
RecipeTimeCard: true,
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(wrapper.find(".ingredient-cell").text()).toContain("flour");
|
|
expect(wrapper.find(".ingredient-cell").text()).not.toContain("120");
|
|
const steps = wrapper.findAll(".recipe-step-body");
|
|
expect(steps).toHaveLength(2);
|
|
expect(steps[0].element.parentElement?.textContent).toContain("120 °C");
|
|
expect(steps[0].element.parentElement?.textContent).toContain("3m");
|
|
expect(steps[1].element.parentElement?.textContent).not.toContain("120 °C");
|
|
});
|
|
});
|