what-to-cook/test/empty-screen.test.js
Peppa f4f4c7a219
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-44: тест, что на пустом экране лишних кнопок нет
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 06:52:36 +05:00

25 lines
1.2 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";
const read = (f) => readFileSync(new URL(`../src/${f}`, import.meta.url), "utf8");
test("Сценарий: на пустом списке «Полегче» и «Посложнее» скрыты", () => {
assert.match(read("app.js"), /\$\("tune"\)\.hidden = \$\("tuneInfo"\)\.hidden = n === 0/);
});
test("Сценарий: «Назад» только внутри карточки рецепта", () => {
const h = read("index.html");
const recipe = h.slice(h.indexOf('<article id="recipe"'));
const home = h.slice(0, h.indexOf('<article id="recipe"'));
assert.match(recipe, /id="back"/);
assert.doesNotMatch(home, /id="back"/);
});
test("Сценарий: [hidden] у блока кнопок действует", () => {
assert.match(read("style.css"), /\[hidden\]\s*\{\s*display:\s*none/);
});
test("Сценарий: на пустом экране «Рецепт» в выдаче скрыт, кнопки блюда ждут выбора", () => {
const h = read("index.html");
assert.match(h, /id="recipeToday"[^>]*hidden/);
assert.match(read("app.js"), /\$\("recipeToday"\)\.hidden = !\(show && findRecipe/);
});