@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
42 lines • 2.39 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const customLockScreenFetchSize_1 = __importDefault(require("./customLockScreenFetchSize"));
const mockTransportGenerator = out => ({ send: () => out });
describe("customLockScreenFetchSize", () => {
test("should return size if available", async () => {
const mockedTransport = mockTransportGenerator(Buffer.from("000089e99000", "hex"));
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore next-line
const response = await (0, customLockScreenFetchSize_1.default)(mockedTransport);
expect(response).toBe(35305);
});
test("should return 0 when no size is returned", async () => {
const mockedTransport = mockTransportGenerator(Buffer.from("000000009000", "hex"));
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore next-line
await expect((0, customLockScreenFetchSize_1.default)(mockedTransport)).resolves.toBe(0);
});
test("unexpected bootloader or any other code, should throw", async () => {
const mockedTransport = mockTransportGenerator(Buffer.from("662d", "hex"));
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore next-line
await expect((0, customLockScreenFetchSize_1.default)(mockedTransport)).rejects.toThrow(Error);
});
/*
* The infinite loop firmware was released before the custom lockscreen feature was
* developed, leaving us with a device that can be updated inifinetely but doesn't
* respond well to these apdus. Since accessing the manager with a stax device will
* automatically trigger this command, we need to handle it, at the very least for
* our engineers.
*/
test("il fw for nano doesn't support the CLS apdus, should still pass with 0", async () => {
const mockedTransport = mockTransportGenerator(Buffer.from("662e", "hex"));
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore next-line
await expect((0, customLockScreenFetchSize_1.default)(mockedTransport)).resolves.toBe(0);
});
});
//# sourceMappingURL=customLockScreenFetchSize.test.js.map