@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
30 lines • 1.61 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const network_1 = __importDefault(require("@ledgerhq/live-network/network"));
const fetchCurrencyFrom_1 = require("../fetchCurrencyFrom");
const fetchCurrencyFrom_mocks_1 = require("../__mocks__/fetchCurrencyFrom.mocks");
const timeout_1 = require("../../../const/timeout");
const flattenV5CurrenciesToAndFrom_1 = require("../../../utils/flattenV5CurrenciesToAndFrom");
jest.mock("@ledgerhq/live-network/network");
describe("fetchCurrencyFrom", () => {
it("success with 200", async () => {
network_1.default.mockImplementation(() => ({
data: fetchCurrencyFrom_mocks_1.fetchCurrencyFromMock,
}));
const providers = ["changelly", "cic", "moonpay", "oneinch", "paraswap"];
const result = await (0, fetchCurrencyFrom_1.fetchCurrencyFrom)({
currencyTo: "bitcoin",
providers,
});
expect(result).toStrictEqual((0, flattenV5CurrenciesToAndFrom_1.flattenV5CurrenciesToAndFrom)(fetchCurrencyFrom_mocks_1.fetchCurrencyFromMock));
expect(network_1.default).toHaveBeenCalledWith({
method: "GET",
timeout: timeout_1.DEFAULT_SWAP_TIMEOUT_MS,
url: "https://swap.ledger.com/v5/currencies/from?providers-whitelist=changelly%2Ccic%2Cmoonpay%2Coneinch%2Cparaswap&additional-coins-flag=false¤cy-to=bitcoin",
});
});
});
//# sourceMappingURL=fetchCurrencyFrom.spec.js.map