32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { after, before, describe, test } from "node:test";
|
|
import { startTestApp, type TestApp } from "./helpers.ts";
|
|
|
|
describe("product-page", () => {
|
|
let app: TestApp;
|
|
before(async () => {
|
|
app = await startTestApp();
|
|
});
|
|
after(() => app.close());
|
|
const get = async (path: string) => {
|
|
const r = await fetch(app.baseUrl + path);
|
|
return { r, text: await r.text() };
|
|
};
|
|
|
|
test("Scenario: Открытие страницы", async () => {
|
|
const { r, text } = await get("/");
|
|
assert.equal(r.status, 200);
|
|
assert.match(r.headers.get("content-type") ?? "", /text\/html/);
|
|
assert.match(text, /Таза Қазақстан/);
|
|
assert.match(text, /Что уже работает/);
|
|
});
|
|
test("Scenario: Выбор языка", async () => {
|
|
const { text } = await get("/?lang=kk");
|
|
assert.match(text, /Қазір не жұмыс істейді/);
|
|
});
|
|
test("Scenario: Неизвестный язык", async () => {
|
|
const { text } = await get("/?lang=xx");
|
|
assert.match(text, /Что уже работает/);
|
|
});
|
|
});
|