node-postgres/test/events.js
Brian C 63caf7cd4c Add 'connect' event to pool (#7)
* Have pool emit 'connect' callback with client

* Ensure pool emits client on connect event
2016-06-22 23:29:35 -05:00

25 lines
544 B
JavaScript

var expect = require('expect.js')
var describe = require('mocha').describe
var it = require('mocha').it
var Pool = require('../')
describe('events', function () {
it('emits connect before callback', function (done) {
var pool = new Pool()
var emittedClient = false
pool.on('connect', function (client) {
emittedClient = client
})
pool.connect(function (err, client, release) {
if (err) return done(err)
release()
pool.end()
expect(client).to.be(emittedClient)
done()
})
})
})