feat: profession description generator
This commit is contained in:
@@ -19,7 +19,12 @@ describe("joinPrerequisiteParts", () => {
|
||||
},
|
||||
{ value: "C", sentenceType: undefined, isMeta: false },
|
||||
]
|
||||
const result = joinPrerequisiteParts(defaultLocaleEnvironment, parts)
|
||||
const result = joinPrerequisiteParts(
|
||||
defaultLocaleEnvironment.translate,
|
||||
defaultLocaleEnvironment.translateMap,
|
||||
defaultLocaleEnvironment.compare,
|
||||
parts.map(part => ({ type: "test", part })),
|
||||
)
|
||||
assert.equal(result, "A, Label for B, C")
|
||||
})
|
||||
|
||||
@@ -32,7 +37,12 @@ describe("joinPrerequisiteParts", () => {
|
||||
{ value: "E", sentenceType: undefined, isMeta: false },
|
||||
{ value: "F", sentenceType: Case("Connected"), isMeta: false },
|
||||
]
|
||||
const result = joinPrerequisiteParts(defaultLocaleEnvironment, parts)
|
||||
const result = joinPrerequisiteParts(
|
||||
defaultLocaleEnvironment.translate,
|
||||
defaultLocaleEnvironment.translateMap,
|
||||
defaultLocaleEnvironment.compare,
|
||||
parts.map(part => ({ type: "test", part })),
|
||||
)
|
||||
assert.equal(result, "A; B; C; D, E; F")
|
||||
})
|
||||
|
||||
@@ -49,7 +59,12 @@ describe("joinPrerequisiteParts", () => {
|
||||
{ value: "I", sentenceType: undefined, isMeta: false },
|
||||
{ value: "J", sentenceType: Case("Standalone"), isMeta: false },
|
||||
]
|
||||
const result = joinPrerequisiteParts(defaultLocaleEnvironment, parts)
|
||||
const result = joinPrerequisiteParts(
|
||||
defaultLocaleEnvironment.translate,
|
||||
defaultLocaleEnvironment.translateMap,
|
||||
defaultLocaleEnvironment.compare,
|
||||
parts.map(part => ({ type: "test", part })),
|
||||
)
|
||||
assert.equal(result, "A. B. C. D, E. F. G. H, I. J.")
|
||||
})
|
||||
|
||||
@@ -59,7 +74,12 @@ describe("joinPrerequisiteParts", () => {
|
||||
{ value: "B", sentenceType: undefined, isMeta: true },
|
||||
{ value: "C", sentenceType: undefined, isMeta: true },
|
||||
]
|
||||
const result = joinPrerequisiteParts(defaultLocaleEnvironment, parts)
|
||||
const result = joinPrerequisiteParts(
|
||||
defaultLocaleEnvironment.translate,
|
||||
defaultLocaleEnvironment.translateMap,
|
||||
defaultLocaleEnvironment.compare,
|
||||
parts.map(part => ({ type: "test", part })),
|
||||
)
|
||||
assert.equal(result, "none, A, B, C")
|
||||
})
|
||||
|
||||
@@ -68,7 +88,13 @@ describe("joinPrerequisiteParts", () => {
|
||||
// @ts-expect-error Testing invalid input
|
||||
{ value: "A", sentenceType: Case("any"), isMeta: true },
|
||||
]
|
||||
const block = () => joinPrerequisiteParts(defaultLocaleEnvironment, parts)
|
||||
const block = () =>
|
||||
joinPrerequisiteParts(
|
||||
defaultLocaleEnvironment.translate,
|
||||
defaultLocaleEnvironment.translateMap,
|
||||
defaultLocaleEnvironment.compare,
|
||||
parts.map(part => ({ type: "test", part })),
|
||||
)
|
||||
assert.throws(block)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { assertExhaustive } from "@elyukai/utils/typeSafety"
|
||||
import { LocaleEnvironment } from "../../src/helpers/locale.js"
|
||||
import { translateMapMock, translateMock } from "./translate.js"
|
||||
import { formatMock, translateMapMock, translateMock } from "./translate.js"
|
||||
|
||||
const localeId = "en-US"
|
||||
|
||||
@@ -21,6 +21,7 @@ const unitListFormat = new Intl.ListFormat(localeId, {
|
||||
*/
|
||||
export const defaultLocaleEnvironment: LocaleEnvironment = {
|
||||
id: "en-US",
|
||||
format: formatMock,
|
||||
translate: translateMock,
|
||||
translateMap: translateMapMock,
|
||||
compare: (x, y) => collator.compare(x, y),
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import { MessageFormat } from "messageformat"
|
||||
import { Translate, TranslateMap } from "../../src/helpers/translate.js"
|
||||
import {
|
||||
Translate,
|
||||
TranslateMap,
|
||||
type Format,
|
||||
} from "../../src/helpers/translate.js"
|
||||
|
||||
/**
|
||||
* A mocked format function.
|
||||
*/
|
||||
export const formatMock: Format = (text, args) =>
|
||||
new MessageFormat("en", text).format(args)
|
||||
|
||||
/**
|
||||
* A mocked translate function.
|
||||
|
||||
Reference in New Issue
Block a user