what-to-cook/test/pick-hint.test.js
2026-11-16 06:33:40 +05:00

25 lines
1.4 KiB
JavaScript
Raw 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";
import { messages } from "../src/i18n.js";
test("Сценарий: рядом с кнопкой подсказка про случайное блюдо на всех языках", () => {
for (const l of ["ru", "kk", "en"]) assert.ok(messages[l].pickHint.length > 10);
assert.match(messages.ru.pickHint, /случайное блюдо/);
const a = readFileSync(new URL("../src/app.js", import.meta.url), "utf8");
assert.match(a, /t\.pickHint/);
});
test("Сценарий: у каждой кнопки в списке есть подпись", () => {
const a = readFileSync(new URL("../src/app.js", import.meta.url), "utf8");
assert.match(a, /removeLabel/);
assert.ok(messages.ru.remove.length > 0);
});
test("Сценарий: подсказка про случайное блюдо видна всегда, отдельно от «сначала добавьте»", () => {
assert.equal(messages.ru.pickHint, "Выберет случайное блюдо из вашего списка.");
const a = readFileSync(new URL("../src/app.js", import.meta.url), "utf8");
assert.match(a, /\$\("pickInfo"\)\.textContent = t\.pickHint/);
assert.doesNotMatch(a, /: t\.pickHint;/);
const h = readFileSync(new URL("../src/index.html", import.meta.url), "utf8");
assert.match(h, /id="pickInfo"/);
});