Skip to content
Myr

session.test.ts

This file

Path

packages/auth/test/session.test.ts

25 lines · 809 bytes · TypeScript

Last changed by

landed by oscabriel6182530

History of this file

Take it

landed by oscabriel6182530

lines 1–25
1import assert from "node:assert/strict";
2import { test } from "node:test";34import { API } from "@burrow/kit";5import { fakeTransport } from "@burrow/kit/testing";67import { currentSession, isMember, signIn } from "../src/index.ts";89const session = { expiresAt: "2031-01-01T00:00:00Z", user: "wren" };1011const { transport } = fakeTransport(12 new Map([13 [`${API}/sessions/t-1`, JSON.stringify(session)],14 [`${API}/teams/ops`, JSON.stringify(["wren", "tamsin"])],15 ])16);1718test("signing in keeps the session as the current one", async () => {19 assert.deepEqual(await signIn("t-1", transport), session);20 assert.deepEqual(currentSession(), session);21});2223test("a session's user is a member of the teams that list them", async () => {24 assert.equal(await isMember(session, "ops", transport), true);25});