diff --git a/test/connection/test_connection.js b/test/connection/test_connection.js index 3cc7bf2..fafa883 100644 --- a/test/connection/test_connection.js +++ b/test/connection/test_connection.js @@ -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'