diff options
| author | Leitwolf | 2026-11-16 14:49:23 +0300 |
|---|---|---|
| committer | GitHub | 2026-11-16 14:49:23 +0300 |
| commit | 324048967d1fb198e3489b1722ca1ff317338550 (patch) | |
| tree | e270ad6dc86200cc79cbdccfa1ef6de1da8aff0d /tests | |
| parent | 45c1bb14326cbee8fe57c6f639550e8eadd81f0a (diff) | |
| parent | 4ee77681379619b3fab7b8b33446a67164216cc8 (diff) | |
| download | tazel.net-main.tar.gz | |
Rewrite the site for the Tazel of C, C++, Objective-C, Objective-C++ and Zig
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/locales.test.mjs | 16 | ||||
| -rw-r--r-- | tests/translations.test.mjs | 39 |
2 files changed, 42 insertions, 13 deletions
diff --git a/tests/locales.test.mjs b/tests/locales.test.mjs index 4af92e8..a0beb97 100644 --- a/tests/locales.test.mjs +++ b/tests/locales.test.mjs @@ -4,19 +4,13 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { - localeOfPrefix, - localePath, - locales, - pageOfPath, - textDirection, -} from "../app/content/locales.ts"; +import { localeOfPrefix, localePath, locales, pageOfPath } from "../app/content/locales.ts"; test("English has no prefix and the other languages have one", () => { assert.equal(localePath("en-US", "/"), "/"); assert.equal(localePath("en-US", "/docs/reference/commands"), "/docs/reference/commands"); assert.equal(localePath("de-DE", "/"), "/de"); - assert.equal(localePath("he-IL", "/docs/reference/commands"), "/he/docs/reference/commands"); + assert.equal(localePath("fr-FR", "/docs/reference/commands"), "/fr/docs/reference/commands"); }); test("a path names its page in every language", () => { @@ -25,7 +19,7 @@ test("a path names its page in every language", () => { assert.equal(pageOfPath(localePath(locale, page)), page); } } - assert.equal(pageOfPath("/ru/docs/reference/lockfile/"), "/docs/reference/lockfile"); + assert.equal(pageOfPath("/ru/docs/reference/build-file/"), "/docs/reference/build-file"); // A path that only starts like a prefix is an English page. assert.equal(pageOfPath("/design"), "/design"); }); @@ -37,7 +31,3 @@ test("a segment that is no prefix names no language", () => { assert.equal(localeOfPrefix("docs"), undefined); assert.equal(localeOfPrefix("en"), undefined); }); - -test("only Hebrew runs from right to left", () => { - assert.deepEqual(locales.map(textDirection), ["ltr", "ltr", "ltr", "rtl"]); -}); diff --git a/tests/translations.test.mjs b/tests/translations.test.mjs new file mode 100644 index 0000000..459c619 --- /dev/null +++ b/tests/translations.test.mjs @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: 2026 Progmasoft <[email protected]> +// SPDX-License-Identifier: AGPL-3.0-or-later + +import assert from "node:assert/strict"; +import { readdirSync, readFileSync } from "node:fs"; +import test from "node:test"; + +import { locales } from "../app/content/locales.ts"; +import { chrome } from "../app/content/chrome.ts"; +import { home } from "../app/content/home.ts"; + +const docsOf = (locale) => + readdirSync(`content/${locale}/docs`, { recursive: true, encoding: "utf8" }) + .filter((file) => file.endsWith(".md")) + .map((file) => file.replaceAll("\\", "/")) + .sort(); + +test("every document exists in every language", () => { + const english = docsOf("en-US"); + assert.ok(english.length > 0); + for (const locale of locales) assert.deepEqual(docsOf(locale), english, locale); +}); + +test("every document has a title and a description", () => { + for (const locale of locales) { + for (const file of docsOf(locale)) { + const text = readFileSync(`content/${locale}/docs/${file}`, "utf8"); + assert.match(text, /^---\ntitle: .+\ndescription: .+\n---\n/, `${locale}/${file}`); + } + } +}); + +test("the frame and the home page are written in every language", () => { + for (const locale of locales) { + assert.ok(chrome[locale], locale); + assert.equal(home[locale].features.length, home["en-US"].features.length, locale); + assert.equal(home[locale].steps.length, home["en-US"].steps.length, locale); + } +}); |