-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathtest.account.escrows.js
106 lines (94 loc) · 3.09 KB
/
test.account.escrows.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
'use strict'
var config = require('../config')
var request = require('request')
var assert = require('assert')
var utils = require('./utils')
var port = config.get('port') || 7111
describe('account escrows API endpoint', function() {
it('should get account escrows', function(done) {
var account = 'rGhDCgik9CwiNpcNnYHkEHcMgw2dkLgtNB'
var url = 'http://localhost:' + port +
'/v2/accounts/' + account + '/escrows'
request({
url: url,
json: true
},
function(err, res, body) {
assert.ifError(err)
assert.strictEqual(res.statusCode, 200)
assert.strictEqual(body.escrows.length, 1)
body.escrows.forEach(function(d) {
assert.strictEqual(d.account, account)
})
done()
})
})
it('should filter by destination', function(done) {
var account = 'rUeXUxaMTH1pELvD2EkiHTRcM9FsH3v4d7'
var url = 'http://localhost:' + port +
'/v2/accounts/' + account + '/escrows'
request({
url: url,
json: true
},
function(err, res, body) {
assert.ifError(err)
assert.strictEqual(res.statusCode, 200)
assert.strictEqual(body.escrows.length, 0)
body.escrows.forEach(function(d) {
assert.strictEqual(d.account, account)
})
done()
})
})
it.skip('handle pagination', function(done) {
var url = 'http://localhost:' + port +
'/v2/accounts/rGhDCgik9CwiNpcNnYHkEHcMgw2dkLgtNB/escrows?'
utils.checkPagination(url, undefined, function(ref, i, body) {
assert.strictEqual(body.escrows.length, 1)
assert.equal(body.escrows[0].amount, ref.escrows[i].amount)
assert.equal(body.escrows[0].tx_hash, ref.escrows[i].tx_hash)
}, done)
})
it.skip('handle pagination (descending false)', function(done) {
var url = 'http://localhost:' + port +
'/v2/accounts/rGhDCgik9CwiNpcNnYHkEHcMgw2dkLgtNB/escrows?'
utils.checkPagination(url, undefined, function(ref, i, body) {
assert.strictEqual(body.escrows.length, 1)
assert.equal(body.escrows[0].amount, ref.escrows[i].amount)
assert.equal(body.escrows[0].tx_hash, ref.escrows[i].tx_hash)
}, done)
})
it('handles empty response', function(done) {
var url = 'http://localhost:' + port +
'/v2/accounts/rrrrUBy92h6worVCYERZcVCzgzgmHb17Dx/escrows'
request({
url: url,
json: true
},
function(err, res, body) {
assert.ifError(err)
assert.strictEqual(res.statusCode, 200)
assert.strictEqual(body.escrows.length, 0)
assert.strictEqual(body.count, 0)
done()
})
})
it.skip('include a link header when marker is present', function(done) {
var url = 'http://localhost:' + port +
'/v2/accounts/rGhDCgik9CwiNpcNnYHkEHcMgw2dkLgtNB/escrows?limit=1'
var linkHeader = '<' + url +
'&marker=rpjZUBy92h6worVCYERZcVCzgzgmHb17Dx' +
'|20150114185210|000011119940|00001> rel="next"'
request({
url: url,
json: true
},
function(err, res) {
assert.ifError(err)
assert.strictEqual(res.statusCode, 200)
assert.strictEqual(res.headers.link, linkHeader)
done()
})
})
})