jest.mock('@steerprotocol/sdk', () => { const Protocol = { Algebra: 'Algebra', AlgebraIntegral: 'AlgebraIntegral', AlgebraIntegralV2: 'AlgebraIntegralV2', DirectionalAlgebra: 'DirectionalAlgebra', MachineX: 'MachineX', ThickV2: 'ThickV2', Shadow: 'Shadow', PoolShark: 'PoolShark', Aerodrome: 'Aerodrome', Blackhole: 'Blackhole', }; return { Protocol, ALGEBRA_PROTOCOLS: [Protocol.Algebra], ALGEBRA_INTEGRAL_PROTOCOLS: [Protocol.AlgebraIntegral], ALGEBRA_INTEGRAL_V_2_0_PROTOCOLS: [Protocol.AlgebraIntegralV2], DIRECTIONAL_ALGEBRA_PROTOCOLS: [Protocol.DirectionalAlgebra], POOLSHARK_PROTOCOLS: [Protocol.PoolShark], AERODROME_PROTOCOLS: [Protocol.Aerodrome], isShadowProtocol: jest.fn( (protocol: string) => protocol === Protocol.Shadow, ), getProtocolTypeByBeacon: jest.fn(), }; }); import { ProtocolDetector } from '../../src/helpers/ProtocolDetector'; describe('ProtocolDetector behavior', () => { const sdk = require('@steerprotocol/sdk'); beforeEach(() => { sdk.getProtocolTypeByBeacon.mockReset(); }); it('returns true for algebra vaults', () => { sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.Algebra); const detector = new ProtocolDetector(); expect(detector.isAlgebraVault('algebra')).toBe(true); }); it('throws when protocol is not found', () => { sdk.getProtocolTypeByBeacon.mockReturnValue(null); const detector = new ProtocolDetector(); expect(() => detector.isPoolSharkVault('missing')).toThrow( 'Protocol not found', ); }); it('detects shadow vaults via helper', () => { sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.Shadow); const detector = new ProtocolDetector(); expect(detector.isShadowVault('shadow')).toBe(true); expect(sdk.isShadowProtocol).toHaveBeenCalledWith(sdk.Protocol.Shadow); }); it('detects specific protocol variants', () => { const detector = new ProtocolDetector(); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.MachineX); expect(detector.isMachineXV3Vault('machine')).toBe(true); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.AlgebraIntegralV2); expect(detector.isAlgebraIntegral19Vault('integral')).toBe(true); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.PoolShark); expect(detector.isPoolSharkVault('poolshark')).toBe(true); sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.Aerodrome); expect(detector.isAerodromeVault('aero')).toBe(true); }); it('returns protocol from getProtocol', () => { sdk.getProtocolTypeByBeacon.mockReturnValue(sdk.Protocol.Blackhole); const detector = new ProtocolDetector(); expect(detector.getProtocol('blackhole')).toBe(sdk.Protocol.Blackhole); }); });