mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-25 16:03:13 +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>
39 lines
1000 B
JavaScript
39 lines
1000 B
JavaScript
'use strict'
|
|
require('./test-helper')
|
|
var Connection = require('../../../lib/connection')
|
|
var Client = require('../../../lib/client')
|
|
|
|
test('emits end when not in query', function () {
|
|
var stream = new (require('events').EventEmitter)()
|
|
stream.setNoDelay = () => {}
|
|
stream.connect = function () {
|
|
// NOOP
|
|
}
|
|
stream.write = function () {
|
|
// NOOP
|
|
}
|
|
|
|
var client = new Client({ connection: new Connection({ stream: stream }) })
|
|
client.connect(
|
|
assert.calls(function () {
|
|
client.query(
|
|
'SELECT NOW()',
|
|
assert.calls(function (err, result) {
|
|
assert(err)
|
|
})
|
|
)
|
|
})
|
|
)
|
|
assert.emits(client, 'error')
|
|
assert.emits(client, 'end')
|
|
client.connection.emit('connect')
|
|
process.nextTick(function () {
|
|
client.connection.emit('readyForQuery')
|
|
assert.equal(client.queryQueue.length, 0)
|
|
assert(client.activeQuery, 'client should have issued query')
|
|
process.nextTick(function () {
|
|
stream.emit('close')
|
|
})
|
|
})
|
|
})
|