"use strict";
// SPDX-License-Identifier: Apache-2.0
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ts_jest_1 = require("@golevelup/ts-jest");
const DataFixture_1 = require("../../../../../../../../__tests__/fixtures/shared/DataFixture");
const EvmAddress_1 = __importDefault(require("../../../../../../../domain/context/contract/EvmAddress"));
const GetKycStatusMockQueryHandler_1 = require("./GetKycStatusMockQueryHandler");
const GetKycStatusMockQuery_1 = require("./GetKycStatusMockQuery");
const ExternalKycListsFixture_1 = require("../../../../../../../../__tests__/fixtures/externalKycLists/ExternalKycListsFixture");
describe("GetKycStatusMockQueryHandler", () => {
    let handler;
    let query;
    const rpcQueryAdapterMock = (0, ts_jest_1.createMock)();
    const contractServiceMock = (0, ts_jest_1.createMock)();
    const accountServiceMock = (0, ts_jest_1.createMock)();
    const contractEvmAddress = new EvmAddress_1.default(DataFixture_1.EvmAddressPropsFixture.create().value);
    const targetEvmAddress = new EvmAddress_1.default(DataFixture_1.EvmAddressPropsFixture.create().value);
    beforeEach(() => {
        handler = new GetKycStatusMockQueryHandler_1.GetKycStatusMockQueryHandler(contractServiceMock, rpcQueryAdapterMock, accountServiceMock);
        query = ExternalKycListsFixture_1.GetKycStatusMockQueryFixture.create();
    });
    afterEach(() => {
        jest.resetAllMocks();
    });
    describe("execute", () => {
        it("should successfully get kyc status mock", async () => {
            contractServiceMock.getContractEvmAddress.mockResolvedValueOnce(contractEvmAddress);
            accountServiceMock.getAccountEvmAddress.mockResolvedValueOnce(targetEvmAddress);
            rpcQueryAdapterMock.getKycStatusMock.mockResolvedValue(1);
            const result = await handler.execute(query);
            expect(result).toBeInstanceOf(GetKycStatusMockQuery_1.GetKycStatusMockQueryResponse);
            expect(result.payload).toBe(1);
            expect(contractServiceMock.getContractEvmAddress).toHaveBeenCalledTimes(1);
            expect(rpcQueryAdapterMock.getKycStatusMock).toHaveBeenCalledTimes(1);
            expect(contractServiceMock.getContractEvmAddress).toHaveBeenCalledWith(query.contractId);
            expect(accountServiceMock.getAccountEvmAddress).toHaveBeenCalledWith(query.targetId);
            expect(rpcQueryAdapterMock.getKycStatusMock).toHaveBeenCalledWith(contractEvmAddress, targetEvmAddress);
        });
    });
});
