Skip to content
Myr

testing.ts

This file

Path

packages/kit/src/testing.ts

21 lines · 541 bytes · TypeScript

Last changed by

landed by oscabriel6182530

History of this file

Take it

landed by oscabriel6182530

lines 1–21
1import type { Transport } from "./transport.ts";
23/**4 * A transport that answers from a table of URL to body, and 404 for any URL5 * not in it. It records each URL it was asked for.6 */7export const fakeTransport = (routes: ReadonlyMap<string, string>) => {8 const asked: string[] = [];910 const transport: Transport = (url) => {11 asked.push(url);1213 const text = routes.get(url);1415 return Promise.resolve(16 text === undefined ? { status: 404, text: "" } : { status: 200, text }17 );18 };1920 return { asked, transport };21};