Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

1.2 KB
Raw Blame
// @vitest-environment happy-dom

import { createApp, nextTick, ref } from "vue";
import { afterEach, describe, expect, it } from "vitest";
import Input from "@/components/ui/input/Input.vue";

const mountedApps: Array<ReturnType<typeof createApp>> = [];

async function mountInput(template: string) {
  const host = document.createElement("div");
  document.body.appendChild(host);
  const app = createApp({
    components: { Input },
    setup() {
      return { value: ref("1") };
    },
    template,
  });
  app.mount(host);
  mountedApps.push(app);
  await nextTick();
  return host;
}

afterEach(() => {
  for (const app of mountedApps.splice(0)) app.unmount();
  document.body.replaceChildren();
});

describe("Input", () => {
  it("uses the plain input for non-number fields", async () => {
    const host = await mountInput('<Input v-model="value" />');

    expect(host.querySelectorAll("input")).toHaveLength(1);
  });

  it("keeps number fields as native inputs and preserves narrow layout classes", async () => {
    const host = await mountInput('<Input v-model="value" type="number" step="2" class="w-14" />');

    expect(host.querySelectorAll("input")).toHaveLength(1);
    expect(host.querySelector("input")?.className).toContain("w-14");
  });
});