21 lines
1.1 KiB
JavaScript
21 lines
1.1 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const html = readFileSync(new URL("../src/index.html", import.meta.url), "utf8");
|
|
const app = readFileSync(new URL("../src/app.js", import.meta.url), "utf8");
|
|
|
|
test("Сценарий: на главном экране «Назад» не появляется, пока рецепт не открыт", () => {
|
|
const recipe = html.slice(html.indexOf('<article id="recipe"'));
|
|
assert.match(html, /<article id="recipe"[^>]*hidden/);
|
|
assert.ok(recipe.includes('id="back"'));
|
|
assert.ok(!html.slice(0, html.indexOf('<article id="recipe"')).includes('id="back"'));
|
|
assert.ok(!html.includes('>Назад<')); // подпись ставит скрипт при открытии рецепта (WTC-42)
|
|
});
|
|
|
|
test("Сценарий: «Назад» возвращает к кнопке, откуда открыт рецепт (список или выдача)", () => {
|
|
assert.match(app, /openRecipe\(d, r\)/);
|
|
assert.match(app, /openRecipe\(state\.last, \$\("recipeToday"\)\)/);
|
|
assert.match(app, /opener\.focus\(\)/);
|
|
});
|