mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 09:46:58 +01:00
Test Connection._req
This commit is contained in:
parent
d4ea4d6ccd
commit
d8cb13ba91
@ -1,5 +1,6 @@
|
||||
import test from 'ava'
|
||||
import sinon from 'sinon'
|
||||
import * as request from '../../src/request' // eslint-disable-line
|
||||
import { Connection } from '../../src'
|
||||
|
||||
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 => {
|
||||
const expectedPath = 'path'
|
||||
const blockId = 'abc'
|
||||
|
Loading…
Reference in New Issue
Block a user