forked from piecesofeightcoin/pancakeswap-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
token.test.ts
33 lines (27 loc) · 1.18 KB
/
token.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { ChainId, Token } from '../src'
describe('Token', () => {
const ADDRESS_ONE = '0x0000000000000000000000000000000000000001'
const ADDRESS_TWO = '0x0000000000000000000000000000000000000002'
describe('#equals', () => {
it('fails if address differs', () => {
expect(new Token(ChainId.MAINNET, ADDRESS_ONE, 18).equals(new Token(ChainId.MAINNET, ADDRESS_TWO, 18))).toBe(
false
)
})
it('true if only decimals differs', () => {
expect(new Token(ChainId.MAINNET, ADDRESS_ONE, 9).equals(new Token(ChainId.MAINNET, ADDRESS_ONE, 18))).toBe(true)
})
it('true if address is the same', () => {
expect(new Token(ChainId.MAINNET, ADDRESS_ONE, 18).equals(new Token(ChainId.MAINNET, ADDRESS_ONE, 18))).toBe(true)
})
it('true on reference equality', () => {
const token = new Token(ChainId.MAINNET, ADDRESS_ONE, 18)
expect(token.equals(token)).toBe(true)
})
it('true even if name/symbol/decimals differ', () => {
const tokenA = new Token(ChainId.MAINNET, ADDRESS_ONE, 9, 'abc', 'def')
const tokenB = new Token(ChainId.MAINNET, ADDRESS_ONE, 18, 'ghi', 'jkl')
expect(tokenA.equals(tokenB)).toBe(true)
})
})
})