@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
41 lines • 1.69 kB
JavaScript
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¶m2=value2¶m2=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¶m1=value1¶m2=value2¶m2=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