29 lines
1.3 KiB
JavaScript
29 lines
1.3 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { exampleStates, addDish } from "../src/logic.js";
|
|
import { catalog } from "../src/catalog.js";
|
|
import { findRecipe } from "../src/recipes.js";
|
|
import { messages } from "../src/i18n.js";
|
|
|
|
// WTC-32
|
|
test("Сценарий: Добавленный пример помечен, остальные доступны", () => {
|
|
const all = exampleStates([], catalog, findRecipe);
|
|
assert.equal(all.length, 4);
|
|
assert.ok(all.every((x) => !x.added));
|
|
const st = exampleStates(addDish([], all[1].name), catalog, findRecipe);
|
|
assert.deepEqual(st.map((x) => x.added), [false, true, false, false]);
|
|
assert.deepEqual(st.map((x) => x.name), all.map((x) => x.name));
|
|
});
|
|
test("Сценарий: Добавлены все четыре — короткий текст", () => {
|
|
let d = [];
|
|
for (const x of exampleStates([], catalog, findRecipe)) d = addDish(d, x.name);
|
|
assert.ok(exampleStates(d, catalog, findRecipe).every((x) => x.added));
|
|
for (const l of ["ru", "kk", "en"]) {
|
|
assert.ok(messages[l].examplesAllAdded.length > 10, l);
|
|
assert.match(messages[l].exampleAdded, /\{name\}/, l);
|
|
}
|
|
const app = readFileSync(new URL("../src/app.js", import.meta.url), "utf8");
|
|
assert.match(app, /b\.disabled = added/);
|
|
});
|