node-postgres/test/unit/client/result-metadata-tests.js
Brian C 8798e50ad3 Re-enable eslint with standard format (#1367)
* 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
2017-07-15 12:05:58 -05:00

38 lines
1.1 KiB
JavaScript

'use strict'
var helper = require(__dirname + '/test-helper')
var testForTag = function (tagText, callback) {
test('includes command tag data for tag ' + tagText, function () {
var client = helper.client()
client.connection.emit('readyForQuery')
var query = client.query('whatever', assert.calls((err, result) => {
assert.ok(result != null, 'should pass something to this event')
callback(result)
}))
assert.lengthIs(client.connection.queries, 1)
client.connection.emit('commandComplete', {
text: tagText
})
client.connection.emit('readyForQuery')
})
}
var check = function (oid, rowCount, command) {
return function (result) {
if (oid != null) {
assert.equal(result.oid, oid)
}
assert.equal(result.rowCount, rowCount)
assert.equal(result.command, command)
}
}
testForTag('INSERT 0 3', check(0, 3, 'INSERT'))
testForTag('INSERT 841 1', check(841, 1, 'INSERT'))
testForTag('DELETE 10', check(null, 10, 'DELETE'))
testForTag('UPDATE 11', check(null, 11, 'UPDATE'))
testForTag('SELECT 20', check(null, 20, 'SELECT'))