UNPKG

@ledgerhq/live-common

Version:
41 lines 1.69 kB
import { appendQueryParamsToManifestURL } from "./appendQueryParamsToManifestURL"; describe("appendQueryParamsToManifestURL", () => { it("appends query parameters to a valid dappUrl", () => { const manifest = { params: { dappUrl: "https://example.com/", }, }; const queryString = { param1: "value1", param2: ["value2", "value3"], }; const url = appendQueryParamsToManifestURL(manifest, queryString); // expect(url).toBeInstanceOf(URL); expect(url?.toString()).toEqual("https://example.com/?param1=value1&param2=value2&param2=value3"); }); it("returns URL when manifest is for a Live App without a dappUrl in manifest.params", () => { const manifest = { id: "mock-id", url: "https://example.com/?manifestParam=existingValue", }; const queryString = { param1: "value1", param2: ["value2", "value3"], }; const url = appendQueryParamsToManifestURL(manifest, queryString); expect(url?.toString()).toBe("https://example.com/?manifestParam=existingValue&param1=value1&param2=value2&param2=value3"); }); it("returns undefined when url is invalid in live app in manifest.params", () => { const manifest = { url: "invalid-url", }; const queryString = { param1: "value1", param2: ["value2", "value3"], }; const url = appendQueryParamsToManifestURL(manifest, queryString); expect(url).toBeUndefined(); }); }); //# sourceMappingURL=appendQueryParamsToManifestURL.test.js.map