mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-08 20:09:19 +00:00
fix tests
This commit is contained in:
@@ -5,13 +5,15 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getRoomIdentifierFromUrl,
|
getRoomIdentifierFromUrl,
|
||||||
getUrlParams,
|
getUrlParams,
|
||||||
|
HeaderStyle,
|
||||||
UserIntent,
|
UserIntent,
|
||||||
} from "../src/UrlParams";
|
} from "../src/UrlParams";
|
||||||
|
import { platform } from "os";
|
||||||
|
|
||||||
const ROOM_NAME = "roomNameHere";
|
const ROOM_NAME = "roomNameHere";
|
||||||
const ROOM_ID = "!d45f138fsd";
|
const ROOM_ID = "!d45f138fsd";
|
||||||
@@ -211,26 +213,68 @@ describe("UrlParams", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("intent", () => {
|
describe("intent", () => {
|
||||||
it("defaults to unknown", () => {
|
const noIntentDefaults = {
|
||||||
expect(getUrlParams().intent).toBe(UserIntent.Unknown);
|
confineToRoom: false,
|
||||||
|
appPrompt: true,
|
||||||
|
preload: false,
|
||||||
|
header: HeaderStyle.Standard,
|
||||||
|
showControls: true,
|
||||||
|
hideScreensharing: false,
|
||||||
|
allowIceFallback: false,
|
||||||
|
perParticipantE2EE: false,
|
||||||
|
controlledAudioDevices: false,
|
||||||
|
skipLobby: false,
|
||||||
|
returnToLobby: false,
|
||||||
|
sendNotificationType: undefined,
|
||||||
|
};
|
||||||
|
const startNewCallDefaults = (platform: string): object => ({
|
||||||
|
confineToRoom: true,
|
||||||
|
appPrompt: false,
|
||||||
|
preload: true,
|
||||||
|
header: platform === "desktop" ? HeaderStyle.None : HeaderStyle.AppBar,
|
||||||
|
showControls: true,
|
||||||
|
hideScreensharing: false,
|
||||||
|
allowIceFallback: true,
|
||||||
|
perParticipantE2EE: true,
|
||||||
|
controlledAudioDevices: platform === "desktop" ? false : true,
|
||||||
|
skipLobby: true,
|
||||||
|
returnToLobby: false,
|
||||||
|
sendNotificationType: "notification",
|
||||||
|
});
|
||||||
|
const joinExistingCallDefaults = (platform: string): object => ({
|
||||||
|
confineToRoom: true,
|
||||||
|
appPrompt: false,
|
||||||
|
preload: true,
|
||||||
|
header: platform === "desktop" ? HeaderStyle.None : HeaderStyle.AppBar,
|
||||||
|
showControls: true,
|
||||||
|
hideScreensharing: false,
|
||||||
|
allowIceFallback: true,
|
||||||
|
perParticipantE2EE: true,
|
||||||
|
controlledAudioDevices: platform === "desktop" ? false : true,
|
||||||
|
skipLobby: false,
|
||||||
|
returnToLobby: false,
|
||||||
|
sendNotificationType: undefined,
|
||||||
|
});
|
||||||
|
it("use no-intent-defaults with unknown intent", () => {
|
||||||
|
expect(getUrlParams()).toMatchObject(noIntentDefaults);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("ignores intent if it is not a valid value", () => {
|
it("ignores intent if it is not a valid value", () => {
|
||||||
expect(getUrlParams("?intent=foo").intent).toBe(UserIntent.Unknown);
|
expect(getUrlParams("?intent=foo")).toMatchObject(noIntentDefaults);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("accepts start_call", () => {
|
it("accepts start_call", () => {
|
||||||
expect(
|
expect(
|
||||||
getUrlParams("?intent=start_call&widgetId=1234&parentUrl=parent.org")
|
getUrlParams("?intent=start_call&widgetId=1234&parentUrl=parent.org"),
|
||||||
.intent,
|
).toMatchObject(startNewCallDefaults("desktop"));
|
||||||
).toBe(UserIntent.StartNewCall);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("accepts join_existing", () => {
|
it("accepts join_existing", () => {
|
||||||
expect(
|
expect(
|
||||||
getUrlParams("?intent=join_existing&widgetId=1234&parentUrl=parent.org")
|
getUrlParams(
|
||||||
.intent,
|
"?intent=join_existing&widgetId=1234&parentUrl=parent.org",
|
||||||
).toBe(UserIntent.JoinExistingCall);
|
),
|
||||||
|
).toMatchObject(joinExistingCallDefaults("desktop"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user