dika/test/server.test.js
Peppa 8ff13c4af6
All checks were successful
peppa/lint lint: success за 0с
peppa/test test: success за 3с
peppa/build build: success за 0с
ci / checks (pull_request) Successful in 10s
deploy / deploy (pull_request) Successful in 15s
DIK-1: список ближайших мест для обеда с бизнес-ланчами и акциями
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 13:06:11 +05:00

17 lines
729 B
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import http from "node:http";
import { handle } from "../src/index.js";
test("healthz и API", async () => {
const s = http.createServer(handle).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();
});