Skip to content

Commit

Permalink
test(server): update tests (signed cookies)
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Feb 10, 2025
1 parent a929c71 commit 8af9f48
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/server/test/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
import { NULL_LOGGER } from "@thi.ng/logger";
import { expect, test } from "bun:test";
import { join, resolve } from "node:path";
Expand Down Expand Up @@ -111,8 +112,8 @@ test("server", async (done) => {
expect(res.status).toBe(200);
expect(res.headers.get("content-type")).toBe("text/plain");
expect(res.headers.get("x-foo")).toBe("bar");
expect(res.headers.get("set-cookie")).toEqual(
"__sid=1234;Max-Age=3600;Secure;HttpOnly;SameSite=Strict;Path=/, user=test"
expect(res.headers.get("set-cookie")).toMatch(
/^__sid=1234:([0-9a-zA-Z_-]+):([0-9a-zA-Z_-]+);Max-Age=3600;Secure;HttpOnly;SameSite=Strict;Path=\/, user=test$/
);
expect(await res.text()).toBe("hello, world (test)");

Expand All @@ -127,8 +128,8 @@ test("server", async (done) => {
expect(res.status).toBe(200);
expect(res.headers.get("content-type")).toBe("application/json");
expect(res.headers.get("content-encoding")).toBe("br");
expect(res.headers.get("set-cookie")).toEqual(
"__sid=1234;Max-Age=3600;Secure;HttpOnly;SameSite=Strict;Path=/, user=undefined"
expect(res.headers.get("set-cookie")).toMatch(
/^__sid=1234:([0-9a-zA-Z_-]+):([0-9a-zA-Z_-]+);Max-Age=3600;Secure;HttpOnly;SameSite=Strict;Path=\/, user=undefined$/
);
expect(await res.json()).toEqual({ status: "ok" });

Expand Down

0 comments on commit 8af9f48

Please sign in to comment.