"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * @jest-environment jsdom
 */
const react_1 = require("@testing-library/react");
const usePickDefaultCurrency_1 = require("./usePickDefaultCurrency");
const currencies_1 = require("../../../currencies");
describe("usePickDefaultCurrency", () => {
    const setCurrency = jest.fn();
    beforeEach(() => {
        setCurrency.mockClear();
    });
    test("do nothing when the passed currency is valid", () => {
        const currencies = [
            (0, currencies_1.getCryptoCurrencyById)("ethereum"),
            (0, currencies_1.getCryptoCurrencyById)("bitcoin"),
            (0, currencies_1.getCryptoCurrencyById)("bsc"),
        ];
        (0, react_1.renderHook)(() => (0, usePickDefaultCurrency_1.usePickDefaultCurrency)(currencies, (0, currencies_1.getCryptoCurrencyById)("ethereum"), setCurrency));
        expect(setCurrency).toHaveBeenCalledTimes(0);
    });
    test("do nothing if the currency is undefined/null and the currencies list don't include eth/btc", () => {
        const currencies = [
            (0, currencies_1.getCryptoCurrencyById)("solana"),
            (0, currencies_1.getCryptoCurrencyById)("polkadot"),
            (0, currencies_1.getCryptoCurrencyById)("bsc"),
        ];
        (0, react_1.renderHook)(() => (0, usePickDefaultCurrency_1.usePickDefaultCurrency)(currencies, undefined, setCurrency));
        expect(setCurrency).toHaveBeenCalledTimes(0);
    });
    test("do nothing if the currency passed isn't valid in the list and the currencies list don't include eth/btc", () => {
        const currencies = [
            (0, currencies_1.getCryptoCurrencyById)("solana"),
            (0, currencies_1.getCryptoCurrencyById)("polkadot"),
            (0, currencies_1.getCryptoCurrencyById)("bsc"),
        ];
        (0, react_1.renderHook)(() => (0, usePickDefaultCurrency_1.usePickDefaultCurrency)(currencies, (0, currencies_1.getCryptoCurrencyById)("stellar"), setCurrency));
        expect(setCurrency).toHaveBeenCalledTimes(0);
    });
    test("returns the ethereum currency if the passed currency isn't valid and ethereum comes before bitcoin in the list", () => {
        const ethereumCurrency = (0, currencies_1.getCryptoCurrencyById)("ethereum");
        const currencies = [
            (0, currencies_1.getCryptoCurrencyById)("bsc"),
            ethereumCurrency,
            (0, currencies_1.getCryptoCurrencyById)("bitcoin"),
            (0, currencies_1.getCryptoCurrencyById)("polkadot"),
        ];
        (0, react_1.renderHook)(() => (0, usePickDefaultCurrency_1.usePickDefaultCurrency)(currencies, (0, currencies_1.getCryptoCurrencyById)("stellar"), setCurrency));
        expect(setCurrency).toHaveBeenCalledTimes(1);
        expect(setCurrency).toHaveBeenCalledWith(ethereumCurrency);
    });
    test("returns the bitcoin currency if the passed currency isn't valid and bitcoin comes before ethereum in the list", () => {
        const bitcoinCurrency = (0, currencies_1.getCryptoCurrencyById)("bitcoin");
        const currencies = [
            (0, currencies_1.getCryptoCurrencyById)("bsc"),
            bitcoinCurrency,
            (0, currencies_1.getCryptoCurrencyById)("ethereum"),
            (0, currencies_1.getCryptoCurrencyById)("polkadot"),
        ];
        (0, react_1.renderHook)(() => (0, usePickDefaultCurrency_1.usePickDefaultCurrency)(currencies, (0, currencies_1.getCryptoCurrencyById)("stellar"), setCurrency));
        expect(setCurrency).toHaveBeenCalledTimes(1);
        expect(setCurrency).toHaveBeenCalledWith(bitcoinCurrency);
    });
});
//# sourceMappingURL=usePickDefaultCurrency.test.js.map