From 28e07d9df3af45881c8508fa7744406069978dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 2 Mar 2016 12:32:11 +0100 Subject: [PATCH] Add forgotten unit test The test should have been added as part of #859 --- test/datasource.test.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/datasource.test.js diff --git a/test/datasource.test.js b/test/datasource.test.js new file mode 100644 index 00000000..db2e098b --- /dev/null +++ b/test/datasource.test.js @@ -0,0 +1,21 @@ +var should = require('./init.js'); +var DataSource = require('../lib/datasource.js').DataSource; + +describe('DataSource', function() { + it('reports helpful error when connector init throws', function() { + var throwingConnector = { + name: 'loopback-connector-throwing', + initialize: function(ds, cb) { + throw new Error('expected test error'); + }, + }; + + (function() { + // this is what LoopBack does + return new DataSource({ + name: 'dsname', + connector: throwingConnector + }); + }).should.throw(/loopback-connector-throwing/); + }); +});