24 lines
1.0 KiB
TypeScript
24 lines
1.0 KiB
TypeScript
// The module's messages: en and lt declare the same keys, or a page in one language breaks.
|
|
|
|
import { buildRegistry } from "@conusai-kit/core"
|
|
import { tenancyModule } from "@conusai-kit/tenancy"
|
|
import { describe, expect, it } from "vitest"
|
|
import { agentModule } from "../index.js"
|
|
|
|
describe("the agent module's messages", () => {
|
|
const catalogues = buildRegistry([tenancyModule, agentModule]).catalogues
|
|
|
|
it("declares en and lt, and every en key resolves in lt", () => {
|
|
const en = catalogues.en?.agent ?? {}
|
|
const lt = catalogues.lt?.agent ?? {}
|
|
const flatten = (tree: Record<string, unknown>, prefix = ""): string[] =>
|
|
Object.entries(tree).flatMap(([key, value]) =>
|
|
typeof value === "string" ? [`${prefix}${key}`] : flatten(value as Record<string, unknown>, `${prefix}${key}.`),
|
|
)
|
|
const enKeys = flatten(en)
|
|
const ltKeys = new Set(flatten(lt))
|
|
expect(enKeys.length).toBeGreaterThan(0)
|
|
for (const key of enKeys) expect(ltKeys.has(key), `agent.${key} has no Lithuanian message`).toBe(true)
|
|
})
|
|
})
|