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.1 KB
Raw Blame
import { describe, expect, it } from "vitest";
import * as messages from "../locales/mongodbDatabaseDump";

function leaves(value: Record<string, unknown>, prefix = ""): Record<string, string> {
  return Object.fromEntries(
    Object.entries(value).flatMap(([key, child]) => {
      const path = prefix ? `${prefix}.${key}` : key;
      if (typeof child === "string") return [[path, child]];
      return Object.entries(leaves(child as Record<string, unknown>, path));
    }),
  );
}

describe("MongoDB dump translations", () => {
  const source = leaves(messages.mongodbDatabaseDumpEn);
  for (const [locale, value] of Object.entries(messages)) {
    it(`${locale} includes every key and preserves placeholders`, () => {
      const translated = leaves(value);
      expect(Object.keys(translated).sort()).toEqual(Object.keys(source).sort());
      for (const [key, text] of Object.entries(translated)) {
        expect(text.trim(), key).not.toBe("");
        expect((text.match(/\{\w+\}/g) ?? []).sort(), key).toEqual((source[key]!.match(/\{\w+\}/g) ?? []).sort());
      }
    });
  }
});