diff --git a/src/swap/components/SwapProvider.test.tsx b/src/swap/components/SwapProvider.test.tsx index 039a4b4f44..262ca532c9 100644 --- a/src/swap/components/SwapProvider.test.tsx +++ b/src/swap/components/SwapProvider.test.tsx @@ -306,8 +306,24 @@ describe('SwapProvider', () => { amountTo: '1e-9', isMissingRequiredField: false, maxSlippage: 5, - tokenFrom: ETH_TOKEN, - tokenTo: DEGEN_TOKEN, + tokenFrom: { + address: '', + name: 'ETH', + symbol: 'ETH', + chainId: 8453, + decimals: 18, + image: + 'https://wallet-api-production.s3.amazonaws.com/uploads/tokens/eth_288.png', + }, + tokenTo: { + address: '0x4ed4e862860bed51a9570b96d89af5e1b0efefed', + name: 'DEGEN', + symbol: 'DEGEN', + chainId: 8453, + decimals: 18, + image: + 'https://d3r81g40ycuhqg.cloudfront.net/wallet/wais/3b/bf/3bbf118b5e6dc2f9e7fc607a6e7526647b4ba8f0bea87125f971446d57b296d2-MDNmNjY0MmEtNGFiZi00N2I0LWIwMTItMDUyMzg2ZDZhMWNm', + }, }, }); }); @@ -330,8 +346,24 @@ describe('SwapProvider', () => { amountTo: '10', isMissingRequiredField: false, maxSlippage: 5, - tokenTo: ETH_TOKEN, - tokenFrom: DEGEN_TOKEN, + tokenTo: { + address: '', + name: 'ETH', + symbol: 'ETH', + chainId: 8453, + decimals: 18, + image: + 'https://wallet-api-production.s3.amazonaws.com/uploads/tokens/eth_288.png', + }, + tokenFrom: { + address: '0x4ed4e862860bed51a9570b96d89af5e1b0efefed', + name: 'DEGEN', + symbol: 'DEGEN', + chainId: 8453, + decimals: 18, + image: + 'https://d3r81g40ycuhqg.cloudfront.net/wallet/wais/3b/bf/3bbf118b5e6dc2f9e7fc607a6e7526647b4ba8f0bea87125f971446d57b296d2-MDNmNjY0MmEtNGFiZi00N2I0LWIwMTItMDUyMzg2ZDZhMWNm', + }, }, }); }); @@ -422,6 +454,7 @@ describe('SwapProvider', () => { it('should pass the correct slippage to getSwapQuote', async () => { const TestComponent = () => { const { handleAmountChange } = useSwapContext(); + // biome-ignore lint: hello React.useEffect(() => { const initializeSwap = () => { handleAmountChange('from', '100', ETH_TOKEN, DEGEN_TOKEN); @@ -435,18 +468,12 @@ describe('SwapProvider', () => { }); expect(getSwapQuote).toHaveBeenCalledWith( expect.objectContaining({ + maxSlippage: '10', amount: '100', amountReference: 'from', from: ETH_TOKEN, to: DEGEN_TOKEN, useAggregator: true, - lifeCycleStatus: expect.objectContaining({ - statusName: 'init', - statusData: expect.objectContaining({ - maxSlippage: 10, - isMissingRequiredField: expect.any(Boolean), - }), - }), }), ); }); @@ -454,6 +481,7 @@ describe('SwapProvider', () => { it('should pass the correct amountReference to getSwapQuote', async () => { const TestComponent = () => { const { handleAmountChange } = useSwapContext(); + // biome-ignore lint: hello React.useEffect(() => { const initializeSwap = () => { handleAmountChange('to', '100', ETH_TOKEN, DEGEN_TOKEN); @@ -467,18 +495,12 @@ describe('SwapProvider', () => { }); expect(getSwapQuote).toHaveBeenCalledWith( expect.objectContaining({ + maxSlippage: '10', amount: '100', amountReference: 'from', from: ETH_TOKEN, to: DEGEN_TOKEN, useAggregator: true, - lifeCycleStatus: expect.objectContaining({ - statusName: 'init', - statusData: expect.objectContaining({ - maxSlippage: 10, - isMissingRequiredField: expect.any(Boolean), - }), - }), }), ); }); @@ -669,4 +691,25 @@ describe('SwapProvider', () => { ).toBe('UNCAUGHT_SWAP_ERROR'); }); }); + + it('should use default maxSlippage when not provided in experimental', () => { + const useTestHook = () => { + const { lifeCycleStatus } = useSwapContext(); + return lifeCycleStatus; + }; + const wrapper = ({ children }) => ( + + + + {children} + + + + ); + const { result } = renderHook(() => useTestHook(), { wrapper }); + expect(result.current.statusName).toBe('init'); + if (result.current.statusName === 'init') { + expect(result.current.statusData.maxSlippage).toBe(3); + } + }); });