26 lines
1.3 KiB
JavaScript
26 lines
1.3 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("Сценарий: у каждой кнопки в разметке есть название (текст или aria-label)", () => {
|
||
for (const [, attrs, text] of html.matchAll(/<button\b([^>]*)>([^<]*)<\/button>/g)) {
|
||
assert.ok(text.trim() || /aria-label="[^"]+"/.test(attrs), attrs);
|
||
}
|
||
});
|
||
|
||
test("Сценарий: поле ввода связано с подписью «Название блюда»", () => {
|
||
assert.match(html, /<label id="nameLabel" for="name">Название блюда<\/label>/);
|
||
assert.match(html, /<input id="name"/);
|
||
});
|
||
|
||
test("Сценарий: кнопки примеров получают название «Добавить «…»»", () => {
|
||
assert.match(app, /b\.textContent = added \? .*t\.addExample\.replace\("\{name\}", name\)/);
|
||
});
|
||
|
||
test("Сценарий: aria-label «Рецепт» не пустеет, когда блюда нет", () => {
|
||
assert.doesNotMatch(app, /\$\("recipeToday"\)\.setAttribute\("aria-label", show \? [^:]+: ""\)/);
|
||
});
|