@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
26 lines • 1.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const errors_1 = require("@ledgerhq/errors");
const uninstallAllApps_1 = require("./uninstallAllApps");
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore next-line
const mockTransportGenerator = out => ({ send: () => out });
describe("uninstallAllApps", () => {
test("should complete with TRUE if user approves", async () => {
const mockedTransport = mockTransportGenerator(Buffer.from(errors_1.StatusCodes.OK.toString(16), "hex"));
await expect((0, uninstallAllApps_1.command)(mockedTransport)).resolves.toBeTruthy();
});
test("should complete with FALSE if the APDU is unavailable", async () => {
const mockedTransport = mockTransportGenerator(Buffer.from(errors_1.StatusCodes.UNKNOWN_APDU.toString(16), "hex"));
await expect((0, uninstallAllApps_1.command)(mockedTransport)).resolves.toBeFalsy();
});
test("should fail with correct error if user refuses", async () => {
const mockedTransport = mockTransportGenerator(Buffer.from(errors_1.StatusCodes.USER_REFUSED_ON_DEVICE.toString(16), "hex"));
await expect((0, uninstallAllApps_1.command)(mockedTransport)).rejects.toThrow(errors_1.UserRefusedOnDevice);
});
test("should throw if any other status", async () => {
const mockedTransport = mockTransportGenerator(Buffer.from(errors_1.StatusCodes.INS_NOT_SUPPORTED.toString(16), "hex"));
await expect((0, uninstallAllApps_1.command)(mockedTransport)).rejects.toThrow(Error);
});
});
//# sourceMappingURL=uninstallAllApps.test.js.map