148 lines
3.6 KiB
TypeScript
148 lines
3.6 KiB
TypeScript
import { describe, expect, it } from "vitest"
|
|
|
|
import type { AdminMessages } from "./messages"
|
|
import { translateMessage } from "./messages"
|
|
|
|
const messages: AdminMessages = {
|
|
common: {
|
|
language: "Language",
|
|
localeNames: {
|
|
de: "German",
|
|
en: "English",
|
|
es: "Spanish",
|
|
fr: "French",
|
|
},
|
|
},
|
|
auth: {
|
|
badge: "Admin Auth",
|
|
titles: {
|
|
signIn: "Sign in",
|
|
signUpOwner: "Welcome",
|
|
signUpUser: "Create account",
|
|
signUpDisabled: "Registration disabled",
|
|
},
|
|
descriptions: {
|
|
signIn: "Sign in description",
|
|
signUpOwner: "Owner description",
|
|
signUpUser: "User description",
|
|
signUpDisabled: "Disabled description",
|
|
},
|
|
fields: {
|
|
name: "Name",
|
|
emailOrUsername: "Email or username",
|
|
email: "Email",
|
|
username: "Username",
|
|
password: "Password",
|
|
},
|
|
actions: {
|
|
signInIdle: "Sign in",
|
|
signInBusy: "Signing in...",
|
|
signUpOwnerIdle: "Create owner account",
|
|
signUpUserIdle: "Create account",
|
|
signUpBusy: "Creating account...",
|
|
},
|
|
links: {
|
|
needAccount: "Need an account?",
|
|
register: "Register",
|
|
alreadyHaveAccount: "Already have an account?",
|
|
goToSignIn: "Go to sign in",
|
|
},
|
|
messages: {
|
|
ownerCreated: "Owner account created.",
|
|
accountCreated: "Account created.",
|
|
registrationDisabled: "Registration is disabled.",
|
|
},
|
|
errors: {
|
|
nameRequired: "Name is required.",
|
|
signInFailed: "Sign in failed",
|
|
signUpFailed: "Sign up failed",
|
|
networkSignIn: "Network sign in error",
|
|
networkSignUp: "Network sign up error",
|
|
},
|
|
},
|
|
settings: {
|
|
badge: "Admin Settings",
|
|
title: "Settings",
|
|
description: "Settings description",
|
|
actions: {
|
|
backToDashboard: "Back to dashboard",
|
|
},
|
|
registration: {
|
|
title: "Registration",
|
|
description: "Registration description",
|
|
currentStatusLabel: "Current status",
|
|
status: {
|
|
enabled: "Enabled",
|
|
disabled: "Disabled",
|
|
},
|
|
checkboxLabel: "Allow registration",
|
|
actions: {
|
|
save: "Save",
|
|
},
|
|
success: {
|
|
updated: "Updated",
|
|
},
|
|
errors: {
|
|
updateFailed: "Update failed",
|
|
},
|
|
},
|
|
},
|
|
dashboard: {
|
|
badge: "Admin App",
|
|
title: "Content Dashboard",
|
|
description: "Manage content.",
|
|
actions: {
|
|
openRoadmap: "Open roadmap",
|
|
},
|
|
notices: {
|
|
noCrudPermission: "No permission.",
|
|
crudSandboxTag: "MVP0 functional test",
|
|
},
|
|
posts: {
|
|
title: "Posts CRUD Sandbox",
|
|
createTitle: "Create post",
|
|
fields: {
|
|
title: "Title",
|
|
slug: "Slug",
|
|
excerpt: "Excerpt",
|
|
body: "Body",
|
|
status: "Status",
|
|
},
|
|
status: {
|
|
draft: "Draft",
|
|
published: "Published",
|
|
},
|
|
actions: {
|
|
create: "Create post",
|
|
save: "Save changes",
|
|
delete: "Delete",
|
|
},
|
|
errors: {
|
|
createFailed: "Create failed.",
|
|
updateFailed: "Update failed.",
|
|
updateMissingId: "Missing post id.",
|
|
deleteFailed: "Delete failed.",
|
|
deleteMissingId: "Missing post id.",
|
|
},
|
|
success: {
|
|
created: "Post created.",
|
|
updated: "Post updated.",
|
|
deleted: "Post deleted.",
|
|
},
|
|
fallback: {
|
|
noExcerpt: "No excerpt",
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
describe("translateMessage", () => {
|
|
it("resolves nested keys", () => {
|
|
expect(translateMessage(messages, "dashboard.title")).toBe("Content Dashboard")
|
|
})
|
|
|
|
it("returns fallback for unknown keys", () => {
|
|
expect(translateMessage(messages, "dashboard.unknown", "Fallback")).toBe("Fallback")
|
|
})
|
|
})
|