Skip to main content
Module

x/fastro/test/cookie_test.ts

Fast and simple web application framework for deno
Go to Latest
File
const { test } = Deno;import { assertEquals } from "../deps.ts";import { Fastro, Cookie } from "../mod.ts";const addr = "http://localhost:8000";const port = 8000;
test({ name: "NO COOKIE", async fn() { const server = new Fastro(); server.get("/", (req) => { req.send("root"); }); server.listen({ port }); const result = await fetch(addr); const text = await result.text(); assertEquals(text, "root"); server.close(); },});
test({ name: "COOKIE", async fn() { const server = new Fastro({ cookie: true }); server.get("/", (req) => { const cookie: Cookie = { name: "tescookie", value: "tes" }; req.sendWithCookie("cookie", [cookie]); }); server.listen({ port }); const result = await fetch(addr); const cookie = result.headers.get("set-cookie"); await result.text(); assertEquals(cookie, "tescookie=tes;"); server.close(); },});