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.0 KB
Raw Blame
import { describe, expect, it } from "vitest";
import { refreshedKvSelectionSummary } from "@/lib/kv/kvRefreshSelection";
import type { KvKeySummary } from "@/lib/backend/api";

describe("kv refresh selection", () => {
  const keys: KvKeySummary[] = [{ key: "/app/config" }, { key: "/app/feature" }];

  it("keeps the previously selected key when it still exists after refresh", () => {
    expect(refreshedKvSelectionSummary("/app/config", keys)).toEqual({ key: "/app/config" });
  });

  it("clears the selected key when it no longer exists after refresh", () => {
    expect(refreshedKvSelectionSummary("/app/missing", keys)).toBeNull();
  });

  it("does not switch to a colliding display key when the selected byte identity disappears", () => {
    const collision: KvKeySummary[] = [{ key: "[base64:/w==]", keyIdentity: "5b6261736536343a2f773d3d5d" }];

    expect(refreshedKvSelectionSummary("ff", collision)).toBeNull();
    expect(refreshedKvSelectionSummary("5b6261736536343a2f773d3d5d", collision)).toEqual(collision[0]);
  });
});