UNPKG

@ledgerhq/live-common

Version:
73 lines 3.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const support_1 = require("./support"); const LiveConfig_1 = require("@ledgerhq/live-config/LiveConfig"); const config_1 = require("./config"); const device_management_kit_1 = require("@ledgerhq/device-management-kit"); LiveConfig_1.LiveConfig.setConfig(config_1.appConfig); describe("Support.ts", () => { describe("shouldUpgrade", () => { it("should ask for an ugprade for an outdated Bitcoin nano app", () => { expect((0, support_1.shouldUpgrade)("Bitcoin", "0.1.0")).toBe(true); }); it("should not ask for any ugprade for a valid Bitcoin nano app", () => { expect((0, support_1.shouldUpgrade)("Bitcoin", "1.4.0")).toBe(false); }); it("should not ask for any ugprade for a valid Bitcoin nano app with a pre-release tag", () => { expect((0, support_1.shouldUpgrade)("Bitcoin", "1.4.0-dev")).toBe(false); }); }); describe("mustUpgrade", () => { it("should ask an upgrade for an outdated nano app", () => { expect((0, support_1.mustUpgrade)("Ethereum", "0.1.0")).toBe(true); expect((0, support_1.mustUpgrade)("Ethereum", "1.10.2")).toBe(true); expect((0, support_1.mustUpgrade)("Ethereum", "1.10.2-rc")).toBe(true); }); it("should not ask any upgrade for the latest Ethereum nano app", () => { expect((0, support_1.mustUpgrade)("Ethereum", "1.10.3")).toBe(false); }); it("should not ask any upgrade for the latest Ethereum nano app with a pre-release tag for a version equal to the minimum version", () => { expect((0, support_1.mustUpgrade)("Ethereum", "1.10.3-dev")).toBe(false); expect((0, support_1.mustUpgrade)("Ethereum", "1.10.3-rc")).toBe(false); expect((0, support_1.mustUpgrade)("Ethereum", "1.10.3-0")).toBe(false); }); it("should not ask any upgrade for the latest Ethereum nano app with a pre-release tag for a version superior to the minimum version", () => { expect((0, support_1.mustUpgrade)("Ethereum", "1.10.4-dev")).toBe(false); }); }); describe("getMinVersion", () => { beforeAll(() => { LiveConfig_1.LiveConfig.setConfig({ config_nanoapp_solana: { type: "object", default: { minVersion: "1.1.0", nanoxMinVersion: "1.2.0", }, }, config_nanoapp_bitcoin: { type: "object", default: { minVersion: "invalid", }, }, }); }); it("can not compute a missing version", () => { expect((0, support_1.getMinVersion)("Ethereum")).toBeUndefined(); }); it("can not compute an invalid version", () => { expect((0, support_1.getMinVersion)("Bitcoin")).toBeUndefined(); }); it("computes the fallback min version with no specified device model", () => { expect((0, support_1.getMinVersion)("Solana")).toEqual("1.1.0"); }); it("computes the fallback min version with not in config device model", () => { expect((0, support_1.getMinVersion)("Solana", device_management_kit_1.DeviceModelId.STAX)).toEqual("1.1.0"); }); it("computes the specified device model min version", () => { expect((0, support_1.getMinVersion)("Solana", device_management_kit_1.DeviceModelId.NANO_X)).toEqual("1.2.0"); }); }); }); //# sourceMappingURL=support.test.js.map