diff --git a/tauri-app/src/lib/components/detail/TanstackOrderQuote.svelte b/tauri-app/src/lib/components/detail/TanstackOrderQuote.svelte index e1eee6fae..1a013cc56 100644 --- a/tauri-app/src/lib/components/detail/TanstackOrderQuote.svelte +++ b/tauri-app/src/lib/components/detail/TanstackOrderQuote.svelte @@ -103,7 +103,9 @@ {formatUnits(BigInt(item.data.ratio), 18)} ({formatUnits(10n ** 36n / BigInt(item.data.ratio), 18)})({BigInt(item.data.ratio) > 0n + ? formatUnits(10n ** 36n / BigInt(item.data.ratio), 18) + : '0'}) { expect(errorCell).toBeInTheDocument(); }); }); + +test('displays zero for price when io ratio is zero', async () => { + mockIPC((cmd) => { + if (cmd === 'batch_order_quotes') { + return [ + { + success: true, + block_number: '0x123', + pair: { pair_name: 'ETH/USDT', input_index: 0, output_index: 1 }, + data: { maxOutput: '0x158323e942e36d8c', ratio: '0x0' }, + error: undefined, + } satisfies BatchOrderQuotesResponse, + ]; + } + }); + + const queryClient = new QueryClient(); + + render(TanstackOrderQuote, { + props: { + id: '0x123', + order: mockOrderDetailsExtended.order, + }, + context: new Map([['$$_queryClient', queryClient]]), + }); + + await waitFor(() => { + const orderQuoteComponent = screen.getByTestId('bodyRow'); + + expect(orderQuoteComponent).toHaveTextContent('ETH/USDT'); + expect(orderQuoteComponent).toHaveTextContent('1.550122181502135692'); // maxOutput + expect(orderQuoteComponent).toHaveTextContent('0'); // ratio + expect(orderQuoteComponent).toHaveTextContent('(0)'); // inverse price + }); +});