"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require(".");
const index_1 = require("../currencies/index");
describe("getSpecs", () => {
    it("should filter currencies correctly", () => {
        (0, index_1.setSupportedCurrencies)(["bitcoin", "ethereum"]);
        const specs = (0, _1.getSpecs)({ disabled: {}, filter: { currencies: ["bitcoin"] } });
        expect(specs[0].currency.id).toEqual("bitcoin");
    });
    it("should filter families correctly", () => {
        (0, index_1.setSupportedCurrencies)(["bitcoin", "ethereum"]);
        const specs = (0, _1.getSpecs)({ disabled: {}, filter: { families: ["bitcoin"] } });
        expect(specs.length).toBeGreaterThan(0);
        expect(specs.every(spec => spec.currency.family === "bitcoin")).toEqual(true);
    });
    it("should filter by feature correctly", () => {
        (0, index_1.setSupportedCurrencies)(["bitcoin"]);
        const specs = (0, _1.getSpecs)({ disabled: {}, filter: { features: ["send"] } });
        expect(specs[0].mutations.length).toBeGreaterThan(0);
        expect(specs[0].mutations.every(spec => spec.feature === "send")).toEqual(true);
    });
    it("should filter multiple features correctly", () => {
        (0, index_1.setSupportedCurrencies)(["bitcoin"]);
        const currentFilter = ["send", "sendMax"];
        const specs = (0, _1.getSpecs)({ disabled: {}, filter: { features: currentFilter } });
        expect(specs[0].mutations.length).toBeGreaterThan(0);
        expect(specs[0].mutations.every(spec => currentFilter.includes(spec.feature))).toEqual(true);
    });
    it("should filter no features correctly", () => {
        (0, index_1.setSupportedCurrencies)(["bitcoin"]);
        const currentFilter = [];
        const specs = (0, _1.getSpecs)({ disabled: {}, filter: { features: currentFilter } });
        expect(specs[0].mutations.length).toBeGreaterThan(0);
    });
    it("should filter features not set correctly", () => {
        (0, index_1.setSupportedCurrencies)(["bitcoin"]);
        const specs = (0, _1.getSpecs)({ disabled: {}, filter: {} });
        expect(specs[0].mutations.length).toBeGreaterThan(0);
    });
    it("should disable currencies correctly", () => {
        (0, index_1.setSupportedCurrencies)(["bitcoin", "ethereum", "digibyte"]);
        const specs = (0, _1.getSpecs)({ disabled: { currencies: ["digibyte"] }, filter: {} });
        expect(specs.find(spec => spec.currency.id === "digibyte")).toBeFalsy();
        expect(specs.find(spec => spec.currency.id === "ethereum")).toBeTruthy();
        expect(specs.find(spec => spec.currency.id === "bitcoin")).toBeTruthy();
    });
    it("should disable families correctly", () => {
        (0, index_1.setSupportedCurrencies)(["bitcoin", "ethereum", "digibyte"]);
        const specs = (0, _1.getSpecs)({ disabled: { families: ["bitcoin"] }, filter: {} });
        expect(specs.find(spec => spec.currency.family === "bitcoin")).toBeFalsy();
        expect(specs.filter(spec => spec.currency.family === "evm").length).toEqual(1);
    });
    it("should return no specs with no currencies supported", () => {
        (0, index_1.setSupportedCurrencies)([]);
        const specs = (0, _1.getSpecs)({ disabled: { families: ["bitcoin"] }, filter: {} });
        expect(specs.length).toEqual(0);
    });
    it("should return every supported specs with no filter or disabled currencies", () => {
        (0, index_1.setSupportedCurrencies)(["bitcoin", "ethereum"]);
        const specs = (0, _1.getSpecs)({ disabled: {}, filter: {} });
        expect(specs.length).toEqual(2);
    });
    it("should prioritize filtered family over disabled ones", () => {
        (0, index_1.setSupportedCurrencies)(["bitcoin"]);
        const specs = (0, _1.getSpecs)({
            disabled: { families: ["bitcoin"] },
            filter: { families: ["bitcoin"] },
        });
        expect(specs.length).toBeGreaterThan(0);
    });
    it("should prioritize filtered currencies over disabled ones", () => {
        (0, index_1.setSupportedCurrencies)(["bitcoin"]);
        const specs = (0, _1.getSpecs)({
            disabled: { currencies: ["bitcoin"] },
            filter: { currencies: ["bitcoin"] },
        });
        expect(specs.length).toBeGreaterThan(0);
    });
    it("should not return unsupported currencies", () => {
        (0, index_1.setSupportedCurrencies)([]);
        const specs = (0, _1.getSpecs)({
            disabled: {},
            filter: { currencies: ["bitcoin"] },
        });
        expect(specs.length).toEqual(0);
    });
});
//# sourceMappingURL=index.test.js.map