Openstatus
www.openstatus.dev
1import { expect, test } from "bun:test";
2
3import { edgeRouter } from "../edge";
4import { createInnerTRPCContext } from "../trpc";
5
6test("Get Test Workspace", async () => {
7 const ctx = createInnerTRPCContext({
8 req: undefined,
9 session: {
10 user: {
11 id: "1",
12 },
13 },
14 //@ts-expect-error
15 workspace: {
16 id: 1,
17 },
18 });
19
20 const caller = edgeRouter.createCaller(ctx);
21 const result = await caller.workspace.getWorkspace();
22
23 expect(result).toMatchObject({
24 id: 1,
25 slug: "love-openstatus",
26 name: "test",
27 plan: "team",
28 paidUntil: null,
29 stripeId: "stripeId1",
30 subscriptionId: "subscriptionId",
31 updatedAt: expect.any(Date),
32 createdAt: expect.any(Date),
33 endsAt: null,
34 });
35});
36
37test("by default we get the first workspace", async () => {
38 const ctx = createInnerTRPCContext({
39 req: undefined,
40 session: {
41 user: {
42 // @ts-expect-error some issues with types
43 id: 1,
44 },
45 },
46 workspace: undefined,
47 });
48
49 const caller = edgeRouter.createCaller(ctx);
50 const result = await caller.workspace.getWorkspace();
51
52 expect(result).toMatchObject({
53 id: 1,
54 slug: "love-openstatus",
55 name: "test",
56 plan: "team",
57 paidUntil: null,
58 stripeId: "stripeId1",
59 subscriptionId: "subscriptionId",
60 updatedAt: expect.any(Date),
61 createdAt: expect.any(Date),
62 endsAt: null,
63 });
64});