/** * Tests for the root component: it loads product information on mount and * shows it, or the error, in the status bar. */ import { flushPromises, mount } from "@vue/test-utils"; import { createPinia, setActivePinia } from "pinia"; import { beforeEach, describe, expect, it, vi } from "vitest"; const invoke = vi.hoisted(() => vi.fn()); vi.mock("@tauri-apps/api/core", () => ({ invoke })); import App from "../src/App.vue"; describe("App", () => { beforeEach(() => { invoke.mockReset(); setActivePinia(createPinia()); }); it("shows name and version in the status bar", async () => { invoke.mockResolvedValue({ name: "Lutra", version: "0.0.0", slogan: "An otterly perfect IDE" }); const wrapper = mount(App); await flushPromises(); expect(wrapper.get("[data-test=status-bar]").text()).toBe("Lutra 0.0.0"); expect(wrapper.get("[data-test=main]").text()).toBe("An otterly perfect IDE"); }); it("shows the engine error when the call fails", async () => { invoke.mockRejectedValue({ code: "internal", message: "engine unavailable" }); const wrapper = mount(App); await flushPromises(); const bar = wrapper.get("[data-test=status-bar]"); expect(bar.text()).toBe("engine unavailable"); expect(bar.classes()).toContain("status-bar--error"); }); });