Skip to main content
Module

x/oak/deploy_test.ts

A middleware framework for handling HTTP with Deno 🐿️ 🦕
Extremely Popular
Go to Latest
File
// Copyright 2018-2021 the oak authors. All rights reserved. MIT license.
import { assertEquals, createWorker } from "./test_deps.ts";
const notUnstable = (() => { return !(Deno && "emit" in Deno && typeof Deno.emit === "function");})();
Deno.test({ name: "deploy - fetch event API", ignore: notUnstable, async fn() { const worker = await createWorker("./fixtures/deploy_diagnostics.ts", { bundle: false, }); await worker.run(async () => { const [response] = await worker.fetch("/"); assertEquals(await response.json(), { headers: [["host", "localhost"], ["x-forwarded-for", "127.0.0.1"]], ip: "127.0.0.1", ips: ["127.0.0.1"], secure: true, url: "http://localhost/", }); }); },});
Deno.test({ name: "deploy - request event API", ignore: notUnstable, async fn() { const worker = await createWorker("./fixtures/deploy_request_event.ts", { bundle: false, }); await worker.run(async () => { const logs: string[] = []; (async () => { for await (const log of worker.logs) { console.log(log); logs.push(log); } })(); const [response] = await worker.fetch("/"); assertEquals(await response.json(), { headers: [["host", "localhost"], ["x-forwarded-for", "127.0.0.1"]], ip: "127.0.0.1", ips: [], secure: false, url: "https://localhost/", }); }); },});