2026-09-24 22:16:24 -04:00
|
|
|
/*
|
|
|
|
|
Copyright 2026 Lotus Guild
|
|
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
|
|
|
Please see LICENSE in the repository root for full details.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
|
|
2026-09-26 12:49:58 -04:00
|
|
|
import {
|
|
|
|
|
parseLayoutPayload,
|
|
|
|
|
parseSettingsPayload,
|
|
|
|
|
shouldToggleScreenshare,
|
|
|
|
|
} from "./lotusControls";
|
2026-09-24 22:16:24 -04:00
|
|
|
|
|
|
|
|
describe("parseLayoutPayload", () => {
|
|
|
|
|
it("accepts grid and spotlight", () => {
|
|
|
|
|
expect(parseLayoutPayload({ layout: "grid" })).toBe("grid");
|
|
|
|
|
expect(parseLayoutPayload({ layout: "spotlight" })).toBe("spotlight");
|
|
|
|
|
});
|
|
|
|
|
it("rejects anything else", () => {
|
|
|
|
|
expect(parseLayoutPayload({ layout: "pip" })).toBeUndefined();
|
|
|
|
|
expect(parseLayoutPayload({})).toBeUndefined();
|
|
|
|
|
expect(parseLayoutPayload(null)).toBeUndefined();
|
|
|
|
|
expect(parseLayoutPayload("grid")).toBeUndefined();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("parseSettingsPayload", () => {
|
|
|
|
|
it("uses an explicit open flag", () => {
|
|
|
|
|
expect(parseSettingsPayload({ open: true }, true)).toBe(true);
|
|
|
|
|
expect(parseSettingsPayload({ open: false }, false)).toBe(false);
|
|
|
|
|
});
|
|
|
|
|
it("toggles when open is missing or not a boolean", () => {
|
|
|
|
|
expect(parseSettingsPayload({}, false)).toBe(true);
|
|
|
|
|
expect(parseSettingsPayload(undefined, true)).toBe(false);
|
|
|
|
|
expect(parseSettingsPayload({ open: "yes" }, true)).toBe(false);
|
|
|
|
|
});
|
|
|
|
|
});
|
2026-09-26 12:49:58 -04:00
|
|
|
|
|
|
|
|
describe("shouldToggleScreenshare", () => {
|
|
|
|
|
it("toggles only when an explicit on differs from the current state", () => {
|
|
|
|
|
expect(shouldToggleScreenshare({ on: true }, false)).toBe(true);
|
|
|
|
|
expect(shouldToggleScreenshare({ on: true }, true)).toBe(false);
|
|
|
|
|
expect(shouldToggleScreenshare({ on: false }, true)).toBe(true);
|
|
|
|
|
expect(shouldToggleScreenshare({ on: false }, false)).toBe(false);
|
|
|
|
|
});
|
|
|
|
|
it("toggles when on is missing or not a boolean", () => {
|
|
|
|
|
expect(shouldToggleScreenshare({}, false)).toBe(true);
|
|
|
|
|
expect(shouldToggleScreenshare({ on: "yes" }, true)).toBe(true);
|
|
|
|
|
expect(shouldToggleScreenshare(null, true)).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
});
|