what-to-cook/test/screen-text.test.js
Peppa a52ef5739c
All checks were successful
peppa/lint lint: success за 0с
peppa/test test: success за 0с
peppa/build build: success за 0с
ci / checks (pull_request) Successful in 4s
deploy / deploy (pull_request) Successful in 13s
WTC-42: подписи скрытых кнопок убраны из текста страницы
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 06:50:26 +05:00

30 lines
1.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { messages } from "../src/i18n.js";
const html = readFileSync(new URL("../src/index.html", import.meta.url), "utf8");
const app = readFileSync(new URL("../src/app.js", import.meta.url), "utf8");
const m = messages.ru;
test("Сценарий: в разметке нет подписей скрытых кнопок", () => {
for (const s of [m.recipe, m.easier, m.harder, m.back]) {
assert.ok(!html.includes(`>${s}<`), s);
}
});
test("Сценарий: подписи «Полегче/Посложнее» задаются только при непустом списке", () => {
assert.match(app, /\$\("easier"\)\.textContent = n === 0 \? "" : t\.easier/);
assert.match(app, /\$\("harder"\)\.textContent = n === 0 \? "" : t\.harder/);
});
test("Сценарий: «Назад» подписывается при открытии рецепта и очищается при возврате", () => {
assert.match(app, /\$\("back"\)\.textContent = t\.back/);
assert.match(app, /\$\("back"\)\.textContent = ""/);
});
test("Сценарий: в карточке рецепта есть заголовок с названием блюда", () => {
assert.match(html, /<h1 id="recipeTitle">/);
assert.match(app, /\$\("recipeTitle"\)\.textContent = r\.name/);
});