diff --git a/lib/remote-connector.js b/lib/remote-connector.js index 195b1e3..b7dc650 100644 --- a/lib/remote-connector.js +++ b/lib/remote-connector.js @@ -29,14 +29,14 @@ module.exports = RemoteConnector; function RemoteConnector(settings) { assert(typeof settings === 'object', - 'cannot initiaze RemoteConnector without a settings object'); + 'cannot initialize RemoteConnector without a settings object'); this.client = settings.client; this.adapter = settings.adapter || 'rest'; this.protocol = settings.protocol || 'http'; this.root = settings.root || ''; this.host = settings.host || 'localhost'; this.port = settings.port || 3000; - this.remotes = remoting.create(); + this.remotes = remoting.create(settings.options); this.name = 'remote-connector'; if (settings.url) { diff --git a/test/helper.js b/test/helper.js index 962ca8f..9a18d0d 100644 --- a/test/helper.js +++ b/test/helper.js @@ -12,6 +12,7 @@ var remoteConnector = require('..'); exports.createMemoryDataSource = createMemoryDataSource; exports.createModel = createModel; exports.createRemoteDataSource = createRemoteDataSource; +exports.createRemoteDataSourceWithOptions = createRemoteDataSourceWithOptions; exports.createRestAppAndListen = createRestAppAndListen; exports.getUserProperties = getUserProperties; @@ -44,6 +45,14 @@ function createRemoteDataSource(remoteApp) { }); } +function createRemoteDataSourceWithOptions(remoteApp, options) { + return loopback.createDataSource({ + url: 'http://anyURL.com', + connector: remoteConnector, + options: options + }); +} + /** * Used to create models based on a set of options. May associate or link to an * app. diff --git a/test/remote-connector.test.js b/test/remote-connector.test.js index eb002ff..25b57b9 100644 --- a/test/remote-connector.test.js +++ b/test/remote-connector.test.js @@ -134,3 +134,15 @@ describe('Custom Path', function() { }); }); }); + +describe('RemoteConnector with options', () => { + it('should have the remoting options passed to the remote object', () => { + const serverApp = helper.createRestAppAndListen(); + + const datasource = helper.createRemoteDataSourceWithOptions( + serverApp, + {'test': 'abc'}); + + assert.deepEqual(datasource.connector.remotes.options, {test: 'abc'}); + }); +});