forked from Sfippa/api-client-v1-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spec.js
58 lines (46 loc) · 1.36 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
'use strict';
var exchange = require('./index')
, nock = require('nock')
, 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('.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);
});
});
});