feat(i18n): localize admin users backbone
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it } from "vitest"
|
||||
|
||||
import { localizeUserFieldErrors } from "@/actions/user.messages"
|
||||
import { es } from "@/i18n/dictionaries/es"
|
||||
|
||||
const actionCopy = es.admin.users.actions
|
||||
|
||||
describe("user action message localization", () => {
|
||||
it("localizes all 6 known use-case error strings to dictionary keys", () => {
|
||||
expect(
|
||||
localizeUserFieldErrors(
|
||||
{
|
||||
username: ["Username already exists"],
|
||||
email: ["Email already exists"],
|
||||
id: [
|
||||
"User not found",
|
||||
"Cannot remove access from the last active administrator",
|
||||
"You cannot remove your own administrator access",
|
||||
"You cannot deactivate your own user",
|
||||
],
|
||||
},
|
||||
actionCopy,
|
||||
),
|
||||
).toEqual({
|
||||
username: [actionCopy.duplicateUsername],
|
||||
email: [actionCopy.duplicateEmail],
|
||||
id: [
|
||||
actionCopy.notFound,
|
||||
actionCopy.lastActiveAdmin,
|
||||
actionCopy.selfAdminAccess,
|
||||
actionCopy.selfDeactivate,
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
it("keeps unknown messages unchanged", () => {
|
||||
expect(
|
||||
localizeUserFieldErrors({ id: ["Unexpected user issue"] }, actionCopy),
|
||||
).toEqual({ id: ["Unexpected user issue"] })
|
||||
})
|
||||
|
||||
it("returns undefined for undefined input", () => {
|
||||
expect(localizeUserFieldErrors(undefined, actionCopy)).toBeUndefined()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user