Files
calendar/packages/lib/bookingSuccessRedirect.test.ts
T
2025-07-08 00:23:38 +05:30

28 lines
968 B
TypeScript

import { describe, expect, it } from "vitest";
import { getNewSearchParams } from "./bookingSuccessRedirect";
describe("getNewSearchParams", () => {
it("should remove 'embed' param when isEmbed is true", () => {
const searchParams = new URLSearchParams({ embed: "true", foo: "bar" });
const query = { bookingId: "123" };
const result = getNewSearchParams({ query, searchParams, isEmbed: true });
expect(result.get("embed")).toBeNull();
expect(result.get("foo")).toBe("bar");
expect(result.get("bookingId")).toBe("123");
});
it("should keep 'embed' param when isEmbed is false", () => {
const searchParams = new URLSearchParams({ embed: "true", foo: "bar" });
const query = { bookingId: "456" };
const result = getNewSearchParams({ query, searchParams, isEmbed: false });
expect(result.get("embed")).toBe("true");
expect(result.get("foo")).toBe("bar");
expect(result.get("bookingId")).toBe("456");
});
});