mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
When enabling this rule, it's recommended to also *disable* the standard `no-unused-vars` rule. Although `no-unused-vars` is not currently enabled, it seems helpful to explicitly disable it here. See: https://typescript-eslint.io/rules/no-unused-vars/ Co-authored-by: alxndrsn <alxndrsn>
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
'use strict'
|
|
require('./test-helper')
|
|
var Connection = require('../../../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)
|
|
})
|
|
})
|
|
})
|
|
})
|