@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
52 lines • 2.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const LiveConfig_1 = require("@ledgerhq/live-config/LiveConfig");
const _1 = require(".");
const tokens_1 = require("@ledgerhq/cryptoassets/tokens");
describe("Testing CryptoAssetStore", () => {
it("should return the default methods from cryptoassets libs when feature flag does not exists", () => {
LiveConfig_1.LiveConfig.setConfig({
some_other_feature: {
type: "boolean",
default: true,
},
});
const store = (0, _1.getCryptoAssetsStore)();
expect(store.findTokenById).toBe(tokens_1.legacyCryptoAssetsStore.findTokenById);
expect(store.findTokenByAddressInCurrency).toBe(tokens_1.legacyCryptoAssetsStore.findTokenByAddressInCurrency);
});
it("should return the default methods from cryptoassets libs when feature flag is disabled", () => {
LiveConfig_1.LiveConfig.setConfig({
feature_cal_lazy_loading: {
type: "boolean",
default: false,
},
});
const store = (0, _1.getCryptoAssetsStore)();
expect(store.findTokenById).toBe(tokens_1.legacyCryptoAssetsStore.findTokenById);
expect(store.findTokenByAddressInCurrency).toBe(tokens_1.legacyCryptoAssetsStore.findTokenByAddressInCurrency);
});
it("should throw an error when no store is set and feature flag is enabled", () => {
LiveConfig_1.LiveConfig.setConfig({
feature_cal_lazy_loading: {
type: "boolean",
default: true,
},
});
expect(() => (0, _1.getCryptoAssetsStore)()).toThrow("CryptoAssetsStore is not set. Please call setCryptoAssetsStore first.");
});
it("should throw return the new store when feature flag is enabled", () => {
LiveConfig_1.LiveConfig.setConfig({
feature_cal_lazy_loading: {
type: "boolean",
default: true,
},
});
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const newStore = {};
(0, _1.setCryptoAssetsStore)(newStore);
const store = (0, _1.getCryptoAssetsStore)();
expect(store).toBe(newStore);
});
});
//# sourceMappingURL=index.test.js.map