@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
34 lines • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const extractDappURLFromManifest_1 = require("./extractDappURLFromManifest");
describe("extractDappURLFromManifest", () => {
it("returns a valid URL when a valid dappUrl is in manifest.params", () => {
const manifest = {
params: {
dappUrl: "https://example.com/",
},
};
const url = (0, extractDappURLFromManifest_1.extractDappURLFromManifest)(manifest);
expect(url).toBeInstanceOf(URL);
expect(url?.toString()).toEqual(manifest.params.dappUrl);
});
it("returns undefined when the dappUrl is not a valid URL", () => {
const manifest = {
params: {
dappUrl: "invalid-url",
},
};
const url = (0, extractDappURLFromManifest_1.extractDappURLFromManifest)(manifest);
expect(url).toBeUndefined();
});
it("returns undefined when there is no dappUrl in manifest.params", () => {
const manifest = {
params: {
dappName: "foo",
},
};
const url = (0, extractDappURLFromManifest_1.extractDappURLFromManifest)(manifest);
expect(url).toBeUndefined();
});
});
//# sourceMappingURL=extractDappURLFromManifest.test.js.map