diff --git a/lib/handlers/get-unimind/handler.ts b/lib/handlers/get-unimind/handler.ts index fc73c0d9..b75eb58c 100644 --- a/lib/handlers/get-unimind/handler.ts +++ b/lib/handlers/get-unimind/handler.ts @@ -67,9 +67,9 @@ export class GetUnimindHandler extends APIGLambdaHandler ({ + ...jest.requireActual('../../../../lib/util/unimind'), + unimindTradeFilter: jest.fn(), +})) const SAMPLE_ROUTE = { quote: "1234", @@ -59,6 +65,8 @@ describe('Testing get unimind handler', () => { beforeEach(() => { jest.clearAllMocks() + const mockFilter = unimindTradeFilter as jest.Mock + mockFilter.mockReturnValue(true) }) it('Testing correct request and response', async () => { @@ -577,8 +585,10 @@ describe('Testing get unimind handler', () => { const NOT_ON_LIST_PAIR = '0x0000000000000000000000000000000000000000-0x1111111111111111111111111111111111111111-123' it('Both tokens on list → always uses Unimind (no sampling)', async () => { + const mockFilter = unimindTradeFilter as jest.Mock + mockFilter.mockReturnValue(false) // Should not matter - tokens on list bypass filter const quoteMetadata = { - quoteId: 'test-on-list-quote', // Any quoteId should work for tokens on list + quoteId: 'test-quote-id', pair: SAMPLE_SUPPORTED_UNIMIND_PAIR, referencePrice: '4221.21', priceImpact: 0.01, @@ -631,9 +641,11 @@ describe('Testing get unimind handler', () => { ) }) - it('Not on list + passes filter (66%) → uses Unimind', async () => { + it('Not on list + passes filter → uses Unimind', async () => { + const mockFilter = unimindTradeFilter as jest.Mock + mockFilter.mockReturnValue(true) const quoteMetadata = { - quoteId: 'test-quote-0', // This quoteId passes unimindTradeFilter + quoteId: 'test-quote-id', pair: NOT_ON_LIST_PAIR, referencePrice: '4221.21', priceImpact: 0.01, @@ -686,9 +698,11 @@ describe('Testing get unimind handler', () => { ) }) - it('Not on list + fails filter (34%) → uses PUBLIC_STATIC_PARAMETERS', async () => { + it('Not on list + fails filter → uses PUBLIC_STATIC_PARAMETERS', async () => { + const mockFilter = unimindTradeFilter as jest.Mock + mockFilter.mockReturnValue(false) const quoteMetadata = { - quoteId: 'test-quote-fail-filter', // This should fail the filter + quoteId: 'test-quote-id', pair: NOT_ON_LIST_PAIR, referencePrice: '4221.21', priceImpact: 0.01,