53 lines
2.0 KiB
TypeScript
53 lines
2.0 KiB
TypeScript
import { describe, expect, it } from "vitest"
|
|
|
|
import { dictionaries, getDictionary } from "@/i18n/dictionaries"
|
|
|
|
describe("admin users unified form dictionary", () => {
|
|
it("provides unified form Person field keys in English admin.users.form", () => {
|
|
const form = getDictionary("en").admin.users.form
|
|
|
|
expect(form.firstNameLabel).toBe("First Name")
|
|
expect(form.firstNamePlaceholder).toBe("First name")
|
|
expect(form.lastNameLabel).toBe("Last Name")
|
|
expect(form.lastNamePlaceholder).toBe("Last name")
|
|
expect(form.departmentLabel).toBe("Department")
|
|
expect(form.departmentPlaceholder).toBe("Select a department")
|
|
expect(form.phoneLabel).toBe("Phone")
|
|
expect(form.phonePlaceholder).toBe("Phone")
|
|
})
|
|
|
|
it("provides unified form Person field keys in Spanish admin.users.form", () => {
|
|
const form = getDictionary("es").admin.users.form
|
|
|
|
expect(form.firstNameLabel).toBe("Nombre")
|
|
expect(form.firstNamePlaceholder).toBe("Nombre")
|
|
expect(form.lastNameLabel).toBe("Apellido")
|
|
expect(form.lastNamePlaceholder).toBe("Apellido")
|
|
expect(form.departmentLabel).toBe("Departamento")
|
|
expect(form.departmentPlaceholder).toBe("Selecciona un departamento")
|
|
expect(form.phoneLabel).toBe("Teléfono")
|
|
expect(form.phonePlaceholder).toBe("Teléfono")
|
|
})
|
|
|
|
it("maintains structural parity for admin.users.form between English and Spanish after Person keys", () => {
|
|
const enKeys = extractKeyPaths(dictionaries.en.admin.users.form)
|
|
const esKeys = extractKeyPaths(dictionaries.es.admin.users.form)
|
|
|
|
expect(esKeys).toEqual(enKeys)
|
|
})
|
|
})
|
|
|
|
function extractKeyPaths(value: unknown, prefix = ""): string[] {
|
|
if (!isPlainObject(value)) return [prefix]
|
|
|
|
return Object.keys(value)
|
|
.sort()
|
|
.flatMap((key) =>
|
|
extractKeyPaths(value[key], prefix ? `${prefix}.${key}` : key),
|
|
)
|
|
}
|
|
|
|
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
}
|