mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2025-02-14 21:10:32 +01:00
Test Connection._req
This commit is contained in:
parent
d4ea4d6ccd
commit
d8cb13ba91
@ -1,5 +1,6 @@
|
|||||||
import test from 'ava'
|
import test from 'ava'
|
||||||
import sinon from 'sinon'
|
import sinon from 'sinon'
|
||||||
|
import * as request from '../../src/request' // eslint-disable-line
|
||||||
import { Connection } from '../../src'
|
import { Connection } from '../../src'
|
||||||
|
|
||||||
const API_PATH = 'http://localhost:9984/api/v1/'
|
const API_PATH = 'http://localhost:9984/api/v1/'
|
||||||
@ -24,6 +25,24 @@ test('generate API URLS', t => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
test('Request with custom headers', t => {
|
||||||
|
const testConn = new Connection(API_PATH, { hello: 'world' })
|
||||||
|
const expectedOptions = {
|
||||||
|
headers: {
|
||||||
|
hello: 'world',
|
||||||
|
custom: 'headers'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// request is read only, cannot be mocked?
|
||||||
|
sinon.spy(request, 'default')
|
||||||
|
testConn._req(API_PATH, { headers: { custom: 'headers' } })
|
||||||
|
|
||||||
|
t.truthy(request.default.calledWith(API_PATH, expectedOptions))
|
||||||
|
request.default.restore()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
test('Get block for a block id', t => {
|
test('Get block for a block id', t => {
|
||||||
const expectedPath = 'path'
|
const expectedPath = 'path'
|
||||||
const blockId = 'abc'
|
const blockId = 'abc'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user