-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_test.ts
34 lines (29 loc) · 1.09 KB
/
mod_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
34
import { describe, expect, it, run } from 'https://deno.land/x/tincan@1.0.1/mod.ts'
import { endpoints, Zrx } from './mod.ts'
const zrx = new Zrx()
describe('networks', () => {
it('should be set to mainnet by default', () => {
expect(zrx.network).toBe('mainnet')
expect(zrx.base).toBe(endpoints['mainnet'])
})
it('should set network with switchNetwork(network)', () => {
zrx.switchNetwork('avax')
expect(zrx.network).toBe('avax')
expect(zrx.base).toBe(endpoints['avax'])
})
it('should set network from constructor', () => {
const zrx = new Zrx('polygon')
expect(zrx.network).toBe('polygon')
expect(zrx.base).toBe(endpoints['polygon'])
})
})
describe('API endpoints', () => {
it('quote({ from, to, amount })', async () => {
zrx.switchNetwork('polygon')
const quote = await zrx.quote({ from: 'USDC', to: 'USDT', amount: 1_000_000 })
expect(quote.sellAmount).toBe('1000000')
expect(quote.buyTokenAddress).toBe('0xc2132d05d31c914a87c6611c10748aeb04b58e8f')
expect(quote.sellTokenAddress).toBe('0x2791bca1f2de4661ed88a30c99a7a9449aa84174')
})
})
run()