@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
44 lines • 1.44 kB
JavaScript
import { isAppStorageType } from "./types";
jest.mock("@ledgerhq/device-core", () => {
return {
isAppStorageInfo: jest.fn(() => true),
};
});
describe("isAppStorageType", () => {
it("should return true for valid AppStorageType", () => {
const data = {
appDataInfo: {},
appData: "MTA2IFJ1ZSBkdSBUZW1wbGUgNzUwMDMgUGFyaXM=", // 106 Rue du Temple 75003 Paris
};
expect(isAppStorageType(data)).toBe(true);
});
it("should return false for missing appDataInfo", () => {
const data = {
// Missing appDataInfo property
appData: "MTA2IFJ1ZSBkdSBUZW1wbGUgNzUwMDMgUGFyaXM=",
};
expect(isAppStorageType(data)).toBe(false);
});
it("should return false for missing appData", () => {
const data = {
appDataInfo: {},
// Missing appData property
};
expect(isAppStorageType(data)).toBe(false);
});
it("should return false for invalid appData type", () => {
const data = {
appDataInfo: {},
appData: 42, // Invalid appData
};
expect(isAppStorageType(data)).toBe(false);
});
it("should return false for unknown data", () => {
const data = {
// Unknown data
foo: "bar",
};
expect(isAppStorageType(data)).toBe(false);
});
});
//# sourceMappingURL=types.test.js.map