what-to-cook/test/empty-screen.test.js
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/);
});