Files
dbx/apps/desktop/src/components/icons/DatabaseIcon.spec.ts
T

81 lines
2.8 KiB
TypeScript
Vendored

// @vitest-environment happy-dom
import { createApp, nextTick } from "vue";
import { afterEach, describe, expect, it } from "vitest";
import DatabaseIcon from "./DatabaseIcon.vue";
describe("DatabaseIcon", () => {
afterEach(() => {
document.body.innerHTML = "";
});
it("uses the OceanBase asset for Oracle mode", async () => {
const container = document.createElement("div");
document.body.appendChild(container);
const app = createApp(DatabaseIcon, { dbType: "oceanbase-oracle" });
app.mount(container);
await nextTick();
expect(container.querySelector("img")?.getAttribute("src")).toBe("/icons/database/oceanbase.svg");
app.unmount();
});
it("uses the Apache Phoenix asset for the Phoenix JDBC profile", async () => {
const container = document.createElement("div");
document.body.appendChild(container);
const app = createApp(DatabaseIcon, { dbType: "phoenix" });
app.mount(container);
await nextTick();
expect(container.querySelector("img")?.getAttribute("src")).toBe("/icons/database/phoenix.svg");
app.unmount();
});
it("uses the Apache Impala asset instead of the Hive asset", async () => {
const container = document.createElement("div");
document.body.appendChild(container);
const app = createApp(DatabaseIcon, { dbType: "impala" });
app.mount(container);
await nextTick();
const icon = container.querySelector("img");
expect(icon?.getAttribute("src")).toBe("/icons/database/impala.svg");
expect(icon?.classList.contains("database-logo-impala")).toBe(true);
app.unmount();
});
it("uses the Apache Kyuubi asset instead of the Hive asset", async () => {
const container = document.createElement("div");
document.body.appendChild(container);
const app = createApp(DatabaseIcon, { dbType: "kyuubi" });
app.mount(container);
await nextTick();
expect(container.querySelector("img")?.getAttribute("src")).toBe("/icons/database/kyuubi.png");
app.unmount();
});
it("uses the Meilisearch asset", async () => {
const container = document.createElement("div");
document.body.appendChild(container);
const app = createApp(DatabaseIcon, { dbType: "meilisearch" });
app.mount(container);
await nextTick();
expect(container.querySelector("img")?.getAttribute("src")).toBe("/icons/database/meilisearch.svg");
app.unmount();
});
it("falls back to the generic icon when the database type is missing", async () => {
const container = document.createElement("div");
document.body.appendChild(container);
const app = createApp(DatabaseIcon);
app.mount(container);
await nextTick();
expect(container.querySelector("img")).toBeNull();
expect(container.querySelector("svg")).not.toBeNull();
app.unmount();
});
});