// @vitest-environment happy-dom import { createApp, nextTick } from "vue"; import { beforeEach, describe, expect, it, vi } from "vitest"; vi.mock("../ContentArea.vue", () => ({ default: { name: "ContentAreaStub", props: ["activeTab", "activeConnection", "executableSql", "activeOutputView", "formatSqlRequest", "compressSqlRequest", "selectedSql", "cursorPos", "blockDangerousRedisCommands"], emits: ["previewStatement", "focusStatement", "reload"], template: `
`, }, })); import QueryResultSurface from "../QueryResultSurface.vue"; function createHost(): HTMLDivElement { const host = document.createElement("div"); document.body.appendChild(host); return host; } describe("QueryResultSurface mount contract", () => { beforeEach(() => { document.body.innerHTML = ""; }); it("forwards preview and focus statement events to the parent", async () => { const host = createHost(); const onPreviewStatement = vi.fn(); const onFocusStatement = vi.fn(); const app = createApp(QueryResultSurface, { activeTab: { id: "tab-1", title: "SQL", connectionId: "conn-1", database: "db", sql: "SELECT 1", mode: "query", }, activeConnection: undefined, executableSql: "SELECT 1", activeOutputView: "result", formatSqlRequest: null, compressSqlRequest: null, selectedSql: "", cursorPos: 0, blockDangerousRedisCommands: false, onPreviewStatement, onFocusStatement, }); app.mount(host); await nextTick(); host.querySelector