Skip to content

Commit fbb53fa

Browse files
author
Roman Fromrome
committed
added test for valid error throwing in connection try block
1 parent 164aea6 commit fbb53fa

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/integration/orm-exports.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,26 @@ describe("ORM.connect()", function () {
139139
});
140140
});
141141

142+
it("should emit valid error if exception being thrown during connection try", function (done) {
143+
var testConfig = {
144+
protocol : 'mongodb',
145+
href : 'unknownhost',
146+
database : 'unknowndb',
147+
user : '',
148+
password : ''
149+
},
150+
db = ORM.connect(testConfig);
151+
152+
db.on("connect", function (err) {
153+
should.exist(err);
154+
should.equal(err.message.indexOf("Connection protocol not supported"), -1);
155+
err.message.should.not.equal("CONNECTION_URL_NO_PROTOCOL");
156+
err.message.should.not.equal("CONNECTION_URL_EMPTY");
157+
158+
return done();
159+
});
160+
});
161+
142162
it("should not modify connection opts", function (done) {
143163
var opts = {
144164
protocol : 'mysql',

0 commit comments

Comments
 (0)