test: cover bilingual static exports
This commit is contained in:
@@ -24,3 +24,38 @@ test('the production build exports a usable home page', async () => {
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('the production build exports reciprocal English and Persian pages', async () => {
|
||||
const englishHtml = await readFile(path.join(exportRoot, 'index.html'), 'utf8');
|
||||
const persianHtml = await readFile(path.join(exportRoot, 'fa.html'), 'utf8');
|
||||
|
||||
assert.match(englishHtml, /<html[^>]*lang="en"[^>]*dir="ltr"/i);
|
||||
assert.match(englishHtml, /href="\/fa"[^>]*hreflang="fa"/i);
|
||||
assert.match(englishHtml, />Software Engineer</);
|
||||
assert.match(englishHtml, />Quera</);
|
||||
assert.doesNotMatch(englishHtml, />مهندس نرمافزار</);
|
||||
assert.doesNotMatch(englishHtml, />کوئرا</);
|
||||
|
||||
assert.match(persianHtml, /<html[^>]*lang="fa"[^>]*dir="rtl"/i);
|
||||
assert.match(persianHtml, /href="\/"[^>]*hreflang="en"/i);
|
||||
assert.match(persianHtml, /سلام، من امیرحسین خلیلی هستم/);
|
||||
assert.match(persianHtml, /از پیکسل تا محصول/);
|
||||
assert.match(persianHtml, /بهمن ۱۴۰۴ تا امروز/);
|
||||
assert.match(persianHtml, /آبان ۱۴۰۳ تا امروز/);
|
||||
});
|
||||
|
||||
test('Persian source copy uses standard characters and punctuation', async () => {
|
||||
const localizedFiles = [
|
||||
'src/i18n/content.ts',
|
||||
'src/data/projects.ts',
|
||||
'src/data/experience.ts',
|
||||
'src/data/education.ts',
|
||||
'src/data/milestones.ts',
|
||||
];
|
||||
const source = (
|
||||
await Promise.all(localizedFiles.map((file) => readFile(file, 'utf8')))
|
||||
).join('\n');
|
||||
|
||||
assert.doesNotMatch(source, /[يك]/, 'use Persian ی and ک instead of Arabic forms');
|
||||
assert.doesNotMatch(source, /[—–]/, 'use Persian punctuation instead of em/en dashes');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user