UNPKG

@ledgerhq/live-common

Version:
66 lines 2.79 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const isUpdateAvailable_1 = __importDefault(require("./isUpdateAvailable")); const mock_1 = require("../apps/mock"); const LiveConfig_1 = require("@ledgerhq/live-config/LiveConfig"); const config_1 = require("../apps/config"); LiveConfig_1.LiveConfig.setConfig(config_1.appConfig); describe("isUpdateAvailable tests", () => { const scenarios = [ { name: "Old device, outdated app expects no update, needs fw update", deviceInfo: mock_1.deviceInfo155, expectedResult: false, outdatedApp: { name: "Ethereum", version: "1.0.0", flags: 0, }, }, { name: "Old device, up-to-date app expect no update", deviceInfo: mock_1.deviceInfo155, expectedResult: false, outdatedApp: { name: "Ethereum", version: "1.0.0", flags: 0, }, }, // FIXME The deviceInfo used for this scenario only works while its FW version is the one in prod, // whenever the prod version changes this test will start failing because new nano apps don't get pushed on // older FW version. // // The fix for now is to generate and use a new deviceInfo based on prod FW version: // This can be done with REPL: // > Connect on USB a device that's on FW prod version // > https://live.ledger.tools/repl (chrome only) // > WebHid transport or another one // > getAppAndVersion command // > dump the generated data in a new deviceInfo and use it here { name: "New device, outdated app expects an update", deviceInfo: mock_1.deviceInfo222, expectedResult: true, outdatedApp: { name: "Ethereum", version: "1.9.0", }, }, ]; // We part from the fact that we are only calling this when we know the currently // installed application does not meet the minimum so we don't really need more cases // to cover. scenarios.forEach(({ name, deviceInfo, outdatedApp, expectedResult }) => { it(name, async () => { jest.mock("../manager/api"); // I don't know how to avoid the internal API calls to the Manager API. const result = await (0, isUpdateAvailable_1.default)(deviceInfo, outdatedApp); expect(result).toBe(expectedResult); }); }); }); //# sourceMappingURL=isUpdateAvailable.test.js.map