feat(i18n): localize admin users UI surfaces
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { describe, expect, it } from "vitest"
|
||||
|
||||
import { formatUserRole } from "@/app/(dashboard)/admin/users/_components/user.copy"
|
||||
|
||||
describe("user copy helpers", () => {
|
||||
const roleCopy = {
|
||||
ADMIN: "Administrador",
|
||||
MANAGER: "Gerente",
|
||||
STAFF: "Personal",
|
||||
VIEWER: "Visor",
|
||||
}
|
||||
|
||||
const fallbackCopy = {
|
||||
unknownRole: "Rol desconocido",
|
||||
}
|
||||
|
||||
it("formats known role values with localized display labels", () => {
|
||||
expect(formatUserRole("ADMIN", roleCopy, fallbackCopy)).toBe(
|
||||
"Administrador",
|
||||
)
|
||||
expect(formatUserRole("STAFF", roleCopy, fallbackCopy)).toBe("Personal")
|
||||
})
|
||||
|
||||
it("falls back for unknown role values without exposing the raw enum value", () => {
|
||||
expect(formatUserRole("UNKNOWN_ROLE", roleCopy, fallbackCopy)).toBe(
|
||||
"Rol desconocido",
|
||||
)
|
||||
})
|
||||
|
||||
it("falls back for null role values", () => {
|
||||
expect(
|
||||
formatUserRole(null as unknown as string, roleCopy, fallbackCopy),
|
||||
).toBe("Rol desconocido")
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user