feat: unify Person and User creation form with conditional password
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { describe, expect, it } from "vitest"
|
||||
|
||||
import { formatUserRole } from "@/app/(dashboard)/admin/users/_components/user.copy"
|
||||
import {
|
||||
formatPersonDepartment,
|
||||
formatUserRole,
|
||||
} from "@/app/(dashboard)/admin/users/_components/user.copy"
|
||||
|
||||
describe("user copy helpers", () => {
|
||||
const roleCopy = {
|
||||
@@ -34,3 +37,47 @@ describe("user copy helpers", () => {
|
||||
).toBe("Rol desconocido")
|
||||
})
|
||||
})
|
||||
|
||||
describe("formatPersonDepartment helper", () => {
|
||||
const departmentCopy = {
|
||||
IT: "IT",
|
||||
ENGINEERING: "Ingeniería",
|
||||
LOGISTICS: "Logística",
|
||||
TRAFFIC: "Tráfico",
|
||||
DRIVER: "Chofer",
|
||||
ADMINISTRATION: "Administración",
|
||||
SALES: "Ventas",
|
||||
OTHER: "Otro",
|
||||
}
|
||||
|
||||
const fallbackCopy = {
|
||||
unknownDepartment: "Departamento desconocido",
|
||||
}
|
||||
|
||||
it("formats known department values with localized labels", () => {
|
||||
expect(
|
||||
formatPersonDepartment("ENGINEERING", departmentCopy, fallbackCopy),
|
||||
).toBe("Ingeniería")
|
||||
expect(
|
||||
formatPersonDepartment("ADMINISTRATION", departmentCopy, fallbackCopy),
|
||||
).toBe("Administración")
|
||||
})
|
||||
|
||||
it("falls back for unknown department values", () => {
|
||||
expect(
|
||||
formatPersonDepartment("UNKNOWN_DEPT", departmentCopy, fallbackCopy),
|
||||
).toBe("Departamento desconocido")
|
||||
})
|
||||
|
||||
it("falls back for null department values", () => {
|
||||
expect(formatPersonDepartment(null, departmentCopy, fallbackCopy)).toBe(
|
||||
"Departamento desconocido",
|
||||
)
|
||||
})
|
||||
|
||||
it("falls back for undefined department values", () => {
|
||||
expect(
|
||||
formatPersonDepartment(undefined, departmentCopy, fallbackCopy),
|
||||
).toBe("Departamento desconocido")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user