Skip to content

Commit

Permalink
feat: add test case to validate clearing of toTokenAmount on source t…
Browse files Browse the repository at this point in the history
…oken input clear
  • Loading branch information
Nithishvb committed Jan 27, 2025
1 parent 95e4239 commit 8b26ab7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/core/tests/controllers/SwapController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,14 @@ describe('SwapController', () => {
expect(SwapController.state.toTokenAmount).toEqual('')
expect(SwapController.state.toTokenPriceInUSD).toEqual(0)
})

it('should clear to token amount when source token amount is cleared', async () => {
SwapController.setSourceTokenAmount('1.0')
await SwapController.swapTokens()
const toTokenAmount = Number(SwapController.state.toTokenAmount)
expect(toTokenAmount).toBeGreaterThan(0)
SwapController.setSourceTokenAmount('')
await SwapController.swapTokens()
expect(SwapController.state.toTokenAmount).toEqual('')
})
})

0 comments on commit 8b26ab7

Please sign in to comment.