Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/app-bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { App } from "./app";
import {
AppBridge,
buildAllowAttribute,
getToolUiResourceUri,
isToolVisibilityModelOnly,
isToolVisibilityAppOnly,
Expand Down Expand Up @@ -1197,3 +1198,54 @@ describe("isToolVisibilityAppOnly", () => {
});
});
});

describe("buildAllowAttribute", () => {
describe("returns empty string", () => {
it("when permissions is undefined", () => {
expect(buildAllowAttribute(undefined)).toBe("");
});

it("when permissions object is empty", () => {
expect(buildAllowAttribute({})).toBe("");
});
});

describe("returns a single permission directive", () => {
it("when only camera is set", () => {
expect(buildAllowAttribute({ camera: {} })).toBe("camera");
});

it("when only microphone is set", () => {
expect(buildAllowAttribute({ microphone: {} })).toBe("microphone");
});

it("when only geolocation is set", () => {
expect(buildAllowAttribute({ geolocation: {} })).toBe("geolocation");
});

it("when only clipboardWrite is set, maps to clipboard-write", () => {
expect(buildAllowAttribute({ clipboardWrite: {} })).toBe(
"clipboard-write",
);
});
});

describe("returns multiple directives joined with '; '", () => {
it("when camera and microphone are set", () => {
expect(buildAllowAttribute({ camera: {}, microphone: {} })).toBe(
"camera; microphone",
);
});

it("when all permissions are set", () => {
expect(
buildAllowAttribute({
camera: {},
microphone: {},
geolocation: {},
clipboardWrite: {},
}),
).toBe("camera; microphone; geolocation; clipboard-write");
});
});
});
Loading