dika/test/server.test.js
Peppa 41fe7b3394
All checks were successful
peppa/lint lint: success за 0с
peppa/test test: success за 1с
peppa/build build: success за 0с
ci / checks (pull_request) Successful in 8s
deploy / deploy (pull_request) Successful in 17s
DIK-3: скрытие устаревших акций и ланчей, страница правки данных для владельца
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 13:46:48 +05:00

17 lines
745 B
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import http from "node:http";
import { createHandler } from "../src/index.js";
test("healthz и API", async () => {
const s = http.createServer(createHandler()).listen(0);
const base = `http://127.0.0.1:${s.address().port}`;
assert.equal((await fetch(base + "/healthz")).status, 200);
assert.equal((await fetch(base + "/api/venues?lat=x&lng=1")).status, 400);
const list = await (await fetch(base + "/api/venues?lat=51.1283&lng=71.4305")).json();
assert.ok(list.length > 0 && list[0].distance <= list[1].distance);
assert.equal((await fetch(base + "/api/locate?q=zzzzzz")).status, 404);
assert.equal((await fetch(base + "/")).status, 200);
s.close();
});