update
This commit is contained in:
1 parent
3bfeb6b61e
commit
7537a41955
30 files changed
+1441
-85
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
import { CONTENT_LANGUAGES } from './content-languages.ts';
|
||||
import { CATEGORY_PROMPT_EXAMPLES, CATEGORY_FORMULA_RULES, localizedCategoryPromptExample } from './categories/prompt-examples.ts';
|
||||
|
||||
const sections = ['title', 'description', 'meta'] as const;
|
||||
|
||||
describe('localized category prompt examples', () => {
|
||||
it('has meaningful localized examples for every supported content language', () => {
|
||||
assert.equal(Object.keys(CATEGORY_PROMPT_EXAMPLES).length, CONTENT_LANGUAGES.length);
|
||||
const en = CATEGORY_PROMPT_EXAMPLES.en;
|
||||
for (const { value: lang } of CONTENT_LANGUAGES) {
|
||||
for (const section of sections) {
|
||||
const example = localizedCategoryPromptExample(lang, section);
|
||||
assert.ok(example.length >= 45, `${lang}/${section} is too short`);
|
||||
assert.ok(example.includes('{{name}}'), `${lang}/${section} loses the name token`);
|
||||
assert.ok(example.startsWith(CATEGORY_PROMPT_EXAMPLES[lang][section]));
|
||||
assert.ok(example.includes(CATEGORY_FORMULA_RULES[lang][section]));
|
||||
assert.ok(CATEGORY_FORMULA_RULES[lang][section].length > 30, `${lang}/${section} missing detailed formula`);
|
||||
if (lang !== 'en') assert.notEqual(example, en[section], `${lang}/${section} is English`);
|
||||
}
|
||||
}
|
||||
});
|
||||
it('changes the example to match the selected content language, independently of UI locale', () => {
|
||||
assert.match(localizedCategoryPromptExample('hr', 'description'), /Opiši/);
|
||||
assert.match(localizedCategoryPromptExample('sl', 'description'), /Naravno opiši/);
|
||||
assert.match(localizedCategoryPromptExample('ja', 'title'), /商品名/);
|
||||
assert.match(localizedCategoryPromptExample('de', 'title'), /Produkttitel/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user