@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
29 lines • 1.74 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const customLockScreenFetchHash_1 = __importDefault(require("./customLockScreenFetchHash"));
const mockTransportGenerator = out => ({ send: () => out });
describe("customLockScreenFetchHash", () => {
test("should return hash if available", async () => {
const mockedTransport = mockTransportGenerator(Buffer.from("32ee3de100f2bca886aaeeaa31f25e043fab61279cd4d4c123e73d5ce02f3a759000", "hex"));
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore next-line
const response = await (0, customLockScreenFetchHash_1.default)(mockedTransport);
expect(response).toMatch("32ee3de100f2bca886aaeeaa31f25e043fab61279cd4d4c123e73d5ce02f3a75");
});
test("should return empty hash even with the error status code", async () => {
const mockedTransport = mockTransportGenerator(Buffer.from("662e", "hex"));
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore next-line
await expect((0, customLockScreenFetchHash_1.default)(mockedTransport)).resolves.toMatch("");
});
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, customLockScreenFetchHash_1.default)(mockedTransport)).rejects.toThrow(Error);
});
});
//# sourceMappingURL=customLockScreenFetchHash.test.js.map