import { mount } from "@vue/test-utils"; import { describe, expect, test } from "vitest"; import { createVuetify } from "vuetify"; import * as components from "vuetify/components"; import * as directives from "vuetify/directives"; import RecipeStepCooking from "./RecipeStepCooking.vue"; describe("RecipeStepCooking", () => { test("displays numeric and named settings", () => { const wrapper = mount(RecipeStepCooking, { props: { modelValue: { appliance: "thermomix", temperatureCelsius: 120, speed: "spoon", mode: "steaming" } }, }); expect(wrapper.text()).toContain("120 °C"); expect(wrapper.text()).toContain("Speed: spoon"); expect(wrapper.text()).toContain("steaming"); }); test("edits whole degrees without replacing an imported fraction on focus and blur", async () => { const wrapper = mount(RecipeStepCooking, { props: { modelValue: { temperatureCelsius: 37.5 }, edit: true }, global: { plugins: [createVuetify({ components, directives })] }, }); const field = wrapper.findComponent(components.VNumberInput); const input = field.find("input"); expect(field.props("precision")).toBe(0); expect(field.props("step")).toBe(1); expect(input.element.value).toBe("38"); expect(wrapper.text()).toContain("37.5 °C"); await input.trigger("focus"); await input.trigger("blur"); expect(wrapper.emitted("update:modelValue")).toBeUndefined(); await input.setValue("39"); expect(wrapper.emitted("update:modelValue")?.at(-1)).toEqual([{ temperatureCelsius: 39 }]); }); });