Skip to content

Commit

Permalink
test: create unit test for INITIALIZED
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Apr 27, 2020
1 parent cdf315e commit 5a16881
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/unit/dialects/mssql/connection-manager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,29 @@ if (dialect === 'mssql') {
expect(err.parent.message).to.equal('Connection was closed by remote server');
});
});

it('connectionManager._connect() should call connect if state is initialized', function() {
const connectStub = sinon.stub();
const INITIALIZED = { name: 'INITILIZED' };
this.connectionStub.returns({
STATE: { INITIALIZED },
state: INITIALIZED,
connect: connectStub,
once(event, cb) {
if (event === 'connect') {
setTimeout(() => {
cb();
}, 500);
}
},
removeListener: () => {},
on: () => {}
});

return this.instance.dialect.connectionManager._connect(this.config)
.then(() => {
expect(connectStub.called).to.equal(true);
});
});
});
}

0 comments on commit 5a16881

Please sign in to comment.