Completed
Pull Request — master (#99)
by Ruben de
01:05
created

api_client-promises.test.js ➔ ... ➔ client.then   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
dl 0
loc 6
rs 9.4285
nop 1
1
/* jshint -W101, -W098 */
2
var blocktrail = require('../');
3
var assert = require('assert');
4
5
/**
6
 * @type APIClient
7
 */
8
var client = blocktrail.BlocktrailSDK({
9
    apiKey: process.env.BLOCKTRAIL_SDK_APIKEY || "EXAMPLE_BLOCKTRAIL_SDK_NODEJS_APIKEY",
10
    apiSecret: process.env.BLOCKTRAIL_SDK_APISECRET || "EXAMPLE_BLOCKTRAIL_SDK_NODEJS_APISECRET",
11
    btccom: typeof process.env.BLOCKTRAIL_SDK_BTCCOM !== "undefined" ? JSON.parse(process.env.BLOCKTRAIL_SDK_BTCCOM) : true
12
});
13
14
describe("using promises", function() {
15
    it('test block by hash', function(cb) {
16
        client.block("000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf").then(function(block) {
17
            assert.ok(block['hash']);
18
            assert.equal(block['hash'], '000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf');
19
20
            cb();
21
        })
22
        .done();
23
    });
24
25
    it ("should work for address request", function(cb) {
26
        client.address("1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp").then(function(address) {
27
            assert.ok(address['address']);
28
            assert.equal(address['address'], '1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp');
29
30
            cb();
31
        })
32
        .done();
33
    });
34
});
35