diff --git a/src/app.js b/src/app.js index 5d750fd..32f8d31 100644 --- a/src/app.js +++ b/src/app.js @@ -50,6 +50,7 @@ function render() { const examples = hasRecipe(state.dishes, findRecipe) ? [] : recipeExamples(state.dishes, catalog, findRecipe); $("recipeExample").hidden = examples.length === 0; $("recipeExampleHint").textContent = t.recipeExampleHint; + $("suggestHint").textContent = t.suggestHint; $("examplesNote").textContent = t.examplesNote; $("examples").replaceChildren(...examples.map((name) => { const b = document.createElement("button"); diff --git a/src/i18n.js b/src/i18n.js index 5cdbb84..ade4ef0 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -23,6 +23,7 @@ export const messages = { today: "Сегодня готовим:", recipe: "Рецепт", noRecipe: "Рецепта нет", + suggestHint: "Начните вводить — предложим блюда из базы казахской кухни.", fromCatalog: "Из базы", recipeLabel: "Рецепт блюда «{name}»", back: "Назад", @@ -61,6 +62,7 @@ export const messages = { today: "Бүгін дайындаймыз:", recipe: "Рецепт", noRecipe: "Рецепт жоқ", + suggestHint: "Жаза бастаңыз — қазақ тағамдары қорынан тағамдар ұсынамыз.", fromCatalog: "Қордан", recipeLabel: "«{name}» тағамының рецепті", back: "Артқа", @@ -99,6 +101,7 @@ export const messages = { today: "Today you cook:", recipe: "Recipe", noRecipe: "No recipe", + suggestHint: "Start typing — we will suggest dishes from the Kazakh cuisine base.", fromCatalog: "From the base", recipeLabel: "Recipe for “{name}”", back: "Back", diff --git a/src/index.html b/src/index.html index 2590db3..9c34c2c 100644 --- a/src/index.html +++ b/src/index.html @@ -17,6 +17,7 @@ +

diff --git a/test/suggest-hint.test.js b/test/suggest-hint.test.js new file mode 100644 index 0000000..4ded571 --- /dev/null +++ b/test/suggest-hint.test.js @@ -0,0 +1,21 @@ +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); +});