Skip to content

Commit c3b82b0

Browse files
committed
more tests
1 parent b1cc859 commit c3b82b0

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed
Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,39 @@
11
import test from 'ava'
22
import { ClientAccountGetminedblocks } from '../../src/client/ClientAccountGetminedblocks'
33
import { ApiKey } from '../../src/entities/Apikey';
4+
import { Address } from '../../src/entities/Address';
5+
import { decode } from 'querystring'
46
// import { decode } from 'querystring'
57
// const nock = require('nock')
6-
// import { parse } from 'url'
8+
import { parse } from 'url'
79
// import { readFile } from 'fs'
810
// import { promisify } from 'util'
911
//const _readFile = promisify(readFile)
1012

1113
const type = 'block'
12-
const apiKey = 'TRU5Z5MNWIEYP4F6DPH2T53IJWZIZ5GT1W'
14+
const address = new Address('0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b')
15+
const tag = 'latest'
16+
const apiKey = new ApiKey('TRU5Z5MNWIEYP4F6DPH2T53IJWZIZ5GT1W')
17+
18+
const expectedUrl = 'https://api.etherscan.io/api?module=account&action=getminedblocks&address=0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b&blocktype=blocks&page=1&offset=10&apikey=TRU5Z5MNWIEYP4F6DPH2T53IJWZIZ5GT1W'
19+
1320

1421
test('exists', t => {
1522
t.truthy(ClientAccountGetminedblocks)
1623
})
1724

1825
test('can be instantiated', t => {
19-
const oApiKey = new ApiKey(apiKey)
26+
new ClientAccountGetminedblocks(apiKey, 'account', 'getminedblocks', address, tag)
2027
t.pass()
21-
})
28+
})
29+
30+
test('generates the right url', t => {
31+
const c = new ClientAccountGetminedblocks(apiKey, 'account', 'balancemulti', address, tag)
32+
const url = c.toUrl()
33+
const parsedUrl = parse(url, true).query
34+
const parsedExpectedUrl = parse(expectedUrl, true).query
35+
t.is(parsedUrl.action, parsedExpectedUrl.action)
36+
t.is(parsedUrl.module, parsedExpectedUrl.module)
37+
t.is(parsedUrl.address, parsedExpectedUrl.address)
38+
t.is(parsedUrl.tag, parsedExpectedUrl.tag)
39+
})

0 commit comments

Comments
 (0)