forked from Sfippa/api-client-v1-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec.js
71 lines (63 loc) · 1.63 KB
/
spec.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var exchange = require('./index')
var nock = require('nock')
var expect = require('chai').expect
describe('exchange', function () {
describe('.getTicker()', function () {
var ticker = {
USD: {
'15m': 432.52,
last: 432.52,
buy: 432.52,
sell: 433,
symbol: '$'
}
}
nock('https://blockchain.info')
.get('/ticker').times(2)
.reply(200, ticker)
it('should get a list of currency rates', function (done) {
exchange.getTicker()
.then(function (data) {
expect(data).to.deep.equal(ticker)
done()
})
.catch(done)
})
it('should get a single currency if specified', function (done) {
exchange.getTicker({ currency: 'USD' })
.then(function (data) {
expect(data).to.deep.equal(ticker.USD)
done()
})
.catch(done)
})
})
describe('.fromBTC()', function () {
nock('https://blockchain.info')
.get('/frombtc')
.query(true)
.reply(200, '227.13')
it('should convert the currency', function (done) {
exchange.fromBTC(100000000, 'USD')
.then(function (response) {
expect(response).to.equal(227.13)
done()
})
.catch(done)
})
})
describe('.toBTC()', function () {
nock('https://blockchain.info')
.get('/tobtc')
.query(true)
.reply(200, '1,234.1234')
it('should convert the currency', function (done) {
exchange.toBTC(1000, 'USD')
.then(function (data) {
expect(data).to.equal(1234.1234)
done()
})
.catch(done)
})
})
})