what-to-cook/test/suggest-hint.test.js
Peppa 795d91dffd
All checks were successful
peppa/lint lint: success за 1с
peppa/test test: success за 0с
peppa/build build: success за 0с
ci / checks (pull_request) Successful in 3s
deploy / deploy (pull_request) Successful in 13s
WTC-29: spec, архив change, заметка в память
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 06:32:29 +05:00

22 lines
1.0 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";
import { messages } from "../src/i18n.js";
import { suggest, inCatalog } from "../src/logic.js";
import { catalog } from "../src/catalog.js";
test("Сценарий: подсказка под полем на трёх языках", () => {
for (const l of ["ru", "kk", "en"]) assert.ok(messages[l].suggestHint);
assert.match(messages.ru.suggestHint, /Начните вводить/);
assert.match(readFileSync("src/index.html", "utf8"), /id="suggestHint"/);
assert.match(readFileSync("src/app.js", "utf8"), /suggestHint/);
});
test("Сценарий: при вводе названия из базы виден список", () => {
const r = suggest("беш", [], catalog);
assert.ok(r.length > 0);
});
test("Сценарий: пометка только у блюда из базы", () => {
assert.equal(inCatalog("бешбармак", catalog), true);
assert.equal(inCatalog("Мамин пирог", catalog), false);
});