// SPDX-License-Identifier: Apache-2.0
import { createMock } from "@golevelup/ts-jest";
import { EvmAddressPropsFixture } from "../../../../../../../../__tests__/fixtures/shared/DataFixture";
import EvmAddress from "../../../../../../../domain/context/contract/EvmAddress";
import { GetKycStatusMockQueryHandler } from "./GetKycStatusMockQueryHandler";
import { GetKycStatusMockQueryResponse } from "./GetKycStatusMockQuery";
import { GetKycStatusMockQueryFixture } from "../../../../../../../../__tests__/fixtures/externalKycLists/ExternalKycListsFixture";
describe("GetKycStatusMockQueryHandler", () => {
    let handler;
    let query;
    const rpcQueryAdapterMock = createMock();
    const contractServiceMock = createMock();
    const accountServiceMock = createMock();
    const contractEvmAddress = new EvmAddress(EvmAddressPropsFixture.create().value);
    const targetEvmAddress = new EvmAddress(EvmAddressPropsFixture.create().value);
    beforeEach(() => {
        handler = new GetKycStatusMockQueryHandler(contractServiceMock, rpcQueryAdapterMock, accountServiceMock);
        query = 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(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);
        });
    });
});
