Fork Horse repository, listed by its owner. Publisher snapshot.
packages/custom-gatekeeper/__tests__/custom.test.ts
Snapshot at 34e3175
1import { describe, expect, it } from "vitest";
2import {
3 CustomSessionImpl,
4 describeCustomAccount,
5 describeCustomVendor,
6} from "../src/custom.js";
7
8describe("custom-gatekeeper", () => {
9 it("describes an auto-provisioned singleton", () => {
10 expect(describeCustomVendor()).toMatchObject({
11 displayName: "Custom Gatekeeper",
12 autoProvisionsAccount: true,
13 providesAuth: false,
14 });
15 expect(describeCustomAccount()).toMatchObject({
16 displayName: "Custom Gatekeeper",
17 singleton: { tsType: "CustomSession" },
18 });
19 });
20
21 it("labels the gatekeeper with the deployment's configured display name", () => {
22 expect(describeCustomVendor("Fork Horse").displayName).toBe("Fork Horse");
23 expect(describeCustomAccount("Fork Horse").displayName).toBe("Fork Horse");
24 expect(describeCustomVendor(" ").displayName).toBe("Custom Gatekeeper");
25 });
26
27 it("authorizes the observation before returning deployment information", async () => {
28 let observation: unknown;
29 let disposed = false;
30 const session = new CustomSessionImpl(
31 {
32 authorizeObservation(value: unknown) {
33 observation = value;
34 return Promise.resolve();
35 },
36 [Symbol.dispose]() {
37 disposed = true;
38 },
39 },
40 { name: "Acme", message: "Use the internal handbook." },
41 );
42
43 await expect(session.getDeploymentInfo()).resolves.toEqual({
44 name: "Acme",
45 message: "Use the internal handbook.",
46 });
47 expect(observation).toEqual({
48 title: "Read deployment information",
49 description: "Read the custom information configured by this deployment.",
50 });
51
52 session[Symbol.dispose]();
53 expect(disposed).toBe(true);
54 });
55});
56