"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const banner_1 = require("./banner");
const bignumber_js_1 = require("bignumber.js");
const constants_1 = require("./constants");
describe("getAccountBannerState", () => {
    it("returns the delegate banner when balance is not zero and there are no delegations", () => {
        const account = {
            spendableBalance: (0, bignumber_js_1.BigNumber)("1000000000000000000000"),
            multiversxResources: {
                delegations: [],
            },
        };
        const multiversxPreloadData = {
            validators: [
                {
                    contract: constants_1.MULTIVERSX_LEDGER_VALIDATOR_ADDRESS,
                    aprValue: 0.2,
                },
            ],
        };
        const result = (0, banner_1.getAccountBannerState)(account, multiversxPreloadData);
        expect(result).toEqual({
            bannerType: "delegate",
        });
    });
    it("returns no banner when balance is zero and account already has delegations", () => {
        const account = {
            spendableBalance: (0, bignumber_js_1.BigNumber)(0),
            multiversxResources: {
                delegations: [
                    {
                        validatorAddress: "validatorAddress",
                    },
                ],
            },
        };
        const multiversxPreloadData = {
            validators: [
                {
                    contract: constants_1.MULTIVERSX_LEDGER_VALIDATOR_ADDRESS,
                    aprValue: 0.2,
                },
            ],
        };
        const result = (0, banner_1.getAccountBannerState)(account, multiversxPreloadData);
        expect(result).toEqual({
            bannerType: "hidden",
        });
    });
    it("returns no banner when there is no ledger validator", () => {
        const account = {
            spendableBalance: (0, bignumber_js_1.BigNumber)(100),
            multiversxResources: {
                delegations: [
                    {
                        contract: "contract:a",
                    },
                ],
            },
        };
        const multiversxPreloadData = {
            validators: [
                {
                    contract: "123",
                },
            ],
        };
        const result = (0, banner_1.getAccountBannerState)(account, multiversxPreloadData);
        expect(result).toEqual({
            bannerType: "hidden",
        });
    });
    it("returns the redelegation banner when the ledger validator is not the worst validator", () => {
        const account = {
            spendableBalance: (0, bignumber_js_1.BigNumber)(100),
            multiversxResources: {
                delegations: [
                    {
                        contract: "contract:a",
                    },
                ],
            },
        };
        const multiversxPreloadData = {
            validators: [
                {
                    contract: "contract:a",
                    aprValue: 0.1,
                },
                {
                    contract: constants_1.MULTIVERSX_LEDGER_VALIDATOR_ADDRESS,
                    aprValue: 0.2,
                },
                {
                    contract: "contract:b",
                    aprValue: 0.3,
                },
            ],
        };
        const result = (0, banner_1.getAccountBannerState)(account, multiversxPreloadData);
        expect(result).toEqual({
            bannerType: "redelegate",
            worstDelegation: {
                contract: "contract:a",
            },
        });
    });
    it("returns the delegation banner when ledger is the worst validator and the account balance is not zero", () => {
        const account = {
            spendableBalance: (0, bignumber_js_1.BigNumber)("1000000000000000000000"),
            multiversxResources: {
                delegations: [
                    {
                        contract: "contract:a",
                    },
                ],
            },
        };
        const multiversxPreloadData = {
            validators: [
                {
                    contract: "contract:a",
                    aprValue: 0.2,
                },
                {
                    contract: constants_1.MULTIVERSX_LEDGER_VALIDATOR_ADDRESS,
                    aprValue: 0.1,
                },
                {
                    contract: "contract:b",
                    aprValue: 0.3,
                },
            ],
        };
        const result = (0, banner_1.getAccountBannerState)(account, multiversxPreloadData);
        expect(result).toEqual({
            bannerType: "delegate",
        });
    });
    it("returns no banner when ledger is the worst validator and the account balance is zero", () => {
        const account = {
            spendableBalance: (0, bignumber_js_1.BigNumber)(0),
            multiversxResources: {
                delegations: [
                    {
                        contract: "contract:a",
                    },
                ],
            },
        };
        const multiversxPreloadData = {
            validators: [
                {
                    contract: "contract:a",
                    aprValue: 0.2,
                },
                {
                    contract: constants_1.MULTIVERSX_LEDGER_VALIDATOR_ADDRESS,
                    aprValue: 0.1,
                },
                {
                    contract: "contract:b",
                    aprValue: 0.3,
                },
            ],
        };
        const result = (0, banner_1.getAccountBannerState)(account, multiversxPreloadData);
        expect(result).toEqual({
            bannerType: "hidden",
        });
    });
});
//# sourceMappingURL=banner.test.js.map