Skip to content

Commit

Permalink
test: add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alfetopito committed Dec 31, 2024
1 parent 4e489f2 commit d822798
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { getFeeToken } from './getFeeToken' // Adjust the import path as necessary

import { ordersMock } from '../pure/OrdersTableContainer/orders.mock'

const BASE_ORDER = ordersMock[3]

describe('getFeeToken', () => {
it("should return inputToken when that's the fee token", () => {
const input = BASE_ORDER
const expectedOutput = BASE_ORDER.inputToken

const result = getFeeToken(input)

expect(result).toEqual(expectedOutput)
})

it("should return outputToken when that's the fee token", () => {
const input = {
...BASE_ORDER,
executionData: { ...BASE_ORDER.executionData, executedFeeToken: BASE_ORDER.outputToken.address },
}
const expectedOutput = BASE_ORDER.outputToken

const result = getFeeToken(input)

expect(result).toEqual(expectedOutput)
})

it('should return inputToken when there is no fee token', () => {
const input = { ...BASE_ORDER, executionData: { ...BASE_ORDER.executionData, executedFeeToken: null } }
const expectedOutput = BASE_ORDER.inputToken

const result = getFeeToken(input)

expect(result).toEqual(expectedOutput)
})
})

0 comments on commit d822798

Please sign in to comment.