mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
* Work on converting lib to standard * Finish updating lib * Finish linting lib * Format test files * Add .eslintrc with standard format * Supply full path to eslint bin * Move lint command to package.json * Add eslint as dev dependency
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
'use strict'
|
|
var helper = require(__dirname + '/test-helper')
|
|
var Connection = require(__dirname + '/../../../lib/connection')
|
|
|
|
test('drain', function () {
|
|
var con = new Connection({stream: 'NO'})
|
|
var client = new Client({connection: con})
|
|
con.connect = function () {
|
|
con.emit('connect')
|
|
}
|
|
con.query = function () {
|
|
}
|
|
client.connect()
|
|
|
|
var raisedDrain = false
|
|
client.on('drain', function () {
|
|
raisedDrain = true
|
|
})
|
|
|
|
client.query('hello')
|
|
client.query('sup')
|
|
client.query('boom')
|
|
|
|
test('with pending queries', function () {
|
|
test('does not emit drain', function () {
|
|
assert.equal(raisedDrain, false)
|
|
})
|
|
})
|
|
|
|
test('after some queries executed', function () {
|
|
con.emit('readyForQuery')
|
|
test('does not emit drain', function () {
|
|
assert.equal(raisedDrain, false)
|
|
})
|
|
})
|
|
|
|
test('when all queries are sent', function () {
|
|
con.emit('readyForQuery')
|
|
con.emit('readyForQuery')
|
|
test('does not emit drain', function () {
|
|
assert.equal(raisedDrain, false)
|
|
})
|
|
})
|
|
|
|
test('after last query finishes', function () {
|
|
con.emit('readyForQuery')
|
|
test('emits drain', function () {
|
|
process.nextTick(function () {
|
|
assert.ok(raisedDrain)
|
|
})
|
|
})
|
|
})
|
|
})
|