Skip to content
Myr

http.test.ts

This file

Path

examples/burrow/packages/kit/test/http.test.ts

47 lines · 1.3 KiB · TypeScript

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 678c8b8 point at it.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 1–47why, one step back
1import assert from "node:assert/strict";
2import { describe, test } from "node:test";34import { API, http, isHealthy, legacyFetch } from "../src/index.ts";5import { fakeTransport } from "../src/testing.ts";67const routes = new Map([8 [`${API}/greeting`, "hello"],9 [`${API}/search/health`, "ok"],10]);1112describe("http.get", () => {13 test("gives the body of a success", async () => {14 const { transport } = fakeTransport(routes);1516 assert.deepEqual(await http.get(`${API}/greeting`, transport), {17 ok: true,18 text: "hello",19 });20 });2122 test("gives the status of a failure, without throwing", async () => {23 const { transport } = fakeTransport(routes);2425 assert.deepEqual(await http.get(`${API}/missing`, transport), {26 ok: false,27 status: 404,28 });29 });30});3132describe("legacyFetch", () => {33 test("throws on a failure", async () => {34 const { transport } = fakeTransport(routes);3536 await assert.rejects(legacyFetch(`${API}/missing`, transport), /404/u);37 });38});3940describe("isHealthy", () => {41 test("is true for a service that answers, false for one that doesn't", async () => {42 const { transport } = fakeTransport(routes);4344 assert.equal(await isHealthy("search", transport), true);45 assert.equal(await isHealthy("billing", transport), false);46 });47});