jest.mock('ethers', () => { return { Contract: jest.fn().mockImplementation((address, abi, signer) => ({ address, abi, signer, })), }; }); jest.mock('../../src/helpers/ProtocolDetector', () => { return { ProtocolDetector: jest.fn().mockImplementation(() => ({ getProtocol: jest.fn().mockReturnValue('Proto'), })), }; }); jest.mock('../../src/helpers/AbiManager', () => { return { AbiManager: jest.fn().mockImplementation(() => ({ getQuoterV2Abi: jest.fn().mockReturnValue(['quoter-abi']), })), }; }); jest.mock('../../src/helpers/ProtocolConfig', () => { return { getQuoterV2Address: jest.fn().mockReturnValue('0xquoter'), }; }); import { QuoterFactory } from '../../src/helpers/QuoterFactory'; describe('QuoterFactory behavior', () => { it('creates quoter contract with resolved address and ABI', () => { const factory = new QuoterFactory({} as any); const contract = factory.createQuoterV2('beacon', {} as any); expect(contract.address).toBe('0xquoter'); expect(contract.abi).toEqual(['quoter-abi']); }); it('throws when address resolution returns empty', () => { const config = require('../../src/helpers/ProtocolConfig'); config.getQuoterV2Address.mockReturnValueOnce(''); const factory = new QuoterFactory({} as any); expect(() => factory.createQuoterV2('beacon', {} as any)).toThrow( 'QuoterV2 address not found', ); }); });