what-to-cook/test/tune-explain.test.js
Peppa eeb88df3aa
All checks were successful
peppa/lint lint: success за 1с
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-35: объяснить кнопки «Полегче» и «Посложнее»
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 06:40:04 +05:00

27 lines
1.3 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { messages } from "../src/i18n.js";
const read = (f) => readFileSync(new URL(`../src/${f}`, import.meta.url), "utf8");
test("Сценарий: подсказка про «Полегче» и «Посложнее» на всех языках", () => {
for (const l of ["ru", "kk", "en"]) {
for (const k of ["tuneHint", "tuneOff", "tuneDone"]) assert.ok(messages[l][k].length > 5);
assert.match(messages[l].tuneDone, /\{name\}/);
}
assert.match(read("index.html"), /id="tuneInfo"/);
});
test("Сценарий: пока блюда нет, кнопки неактивны и это объяснено", () => {
const a = read("app.js");
assert.match(a, /\$\("easier"\)\.disabled = \$\("harder"\)\.disabled = !show/);
assert.match(a, /t\.tuneOff/);
assert.doesNotMatch(read("index.html"), /id="tune"[^>]*hidden/);
assert.match(read("style.css"), /\.tune button:disabled/);
});
test("Сценарий: после нажатия видно новое блюдо или сообщение, что подходящего нет", () => {
const a = read("app.js");
assert.match(a, /t\.tuneDone\.replace/);
assert.match(a, /showTuneError\(r\.error\)/);
});