From 479efe757d80efadba36641a6471a5767d1fcc88 Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Wed, 27 Dec 2023 10:57:11 +0000 Subject: [PATCH] Fix: don't modify `query` in test setups --- packages/sdk-router/src/module/query.test.ts | 23 ++++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/sdk-router/src/module/query.test.ts b/packages/sdk-router/src/module/query.test.ts index 09d3bda826..811986a44e 100644 --- a/packages/sdk-router/src/module/query.test.ts +++ b/packages/sdk-router/src/module/query.test.ts @@ -183,8 +183,11 @@ describe('#query', () => { }) it('rounds down', () => { - query.minAmountOut = query.minAmountOut.add(1) - const newQuery = applySlippage(query, 50, 10000) + const queryPlusOne = { + ...query, + minAmountOut: query.minAmountOut.add(1), + } + const newQuery = applySlippage(queryPlusOne, 50, 10000) expect(newQuery).toEqual({ swapAdapter: '1', tokenOut: '2', @@ -262,8 +265,11 @@ describe('#query', () => { }) it('rounds down', () => { - query.minAmountOut = query.minAmountOut.add(1) - const newQuery = applySlippage(query, 50, 10000) + const queryPlusOne = { + ...query, + minAmountOut: query.minAmountOut.add(1), + } + const newQuery = applySlippage(queryPlusOne, 50, 10000) expect(newQuery).toEqual({ routerAdapter: '1', tokenOut: '2', @@ -342,9 +348,12 @@ describe('#query', () => { }) it('rounds down', () => { - query.minAmountOut = query.minAmountOut.add(1) - const newQuery = applySlippage(query, 50, 10000) - const newQueryInBips = applySlippageInBips(query, 50) + const queryPlusOne = { + ...query, + minAmountOut: query.minAmountOut.add(1), + } + const newQuery = applySlippage(queryPlusOne, 50, 10000) + const newQueryInBips = applySlippageInBips(queryPlusOne, 50) expect(newQuery).toEqual(newQueryInBips) })