test: add unit tests for buildAllowAttribute (#541)
This commit is contained in:
parent
0b83679909
commit
0f6d653b4a
1 changed files with 52 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ import { App } from "./app";
|
|||
import { LATEST_PROTOCOL_VERSION } from "./types";
|
||||
import {
|
||||
AppBridge,
|
||||
buildAllowAttribute,
|
||||
getToolUiResourceUri,
|
||||
isToolVisibilityModelOnly,
|
||||
isToolVisibilityAppOnly,
|
||||
|
|
@ -2786,3 +2787,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…
Reference in a new issue