@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
27 lines • 1.08 kB
JavaScript
import { getCurrencyConfiguration } from ".";
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
describe("getCurrencyConfiguration", () => {
let getValueByKeySpy;
beforeEach(() => {
getValueByKeySpy = jest.spyOn(LiveConfig, "getValueByKey");
});
describe("when config fetching is successful", () => {
it("should return the related currency config", async () => {
const cosmosCurrencyMock = {
family: "cosmos",
id: "cosmos",
};
getValueByKeySpy.mockReturnValueOnce(cosmosCurrencyMock);
const config = getCurrencyConfiguration(cosmosCurrencyMock);
expect(config).toEqual(cosmosCurrencyMock);
});
});
it("should return an error if currency config is null", async () => {
getValueByKeySpy.mockReturnValueOnce(null);
expect(() => getCurrencyConfiguration({
id: "idontexistasacurrency",
family: "ihavenofamily",
})).toThrow(Error);
});
});
//# sourceMappingURL=index.test.js.map