1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-28 10:09:20 -05:00
denoland-deno/http/cookie_test.ts
2019-04-24 07:38:52 -04:00

25 lines
881 B
TypeScript

// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { ServerRequest } from "./server.ts";
import { getCookie } from "./cookie.ts";
import { assertEquals } from "../testing/asserts.ts";
import { test } from "../testing/mod.ts";
test({
name: "[HTTP] Cookie parser",
fn(): void {
let req = new ServerRequest();
req.headers = new Headers();
assertEquals(getCookie(req), {});
req.headers = new Headers();
req.headers.set("Cookie", "foo=bar");
assertEquals(getCookie(req), { foo: "bar" });
req.headers = new Headers();
req.headers.set("Cookie", "full=of ; tasty=chocolate");
assertEquals(getCookie(req), { full: "of ", tasty: "chocolate" });
req.headers = new Headers();
req.headers.set("Cookie", "igot=99; problems=but...");
assertEquals(getCookie(req), { igot: "99", problems: "but..." });
}
});