node-postgres/test/native/callback-api-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

35 lines
1.0 KiB
JavaScript

'use strict'
var domain = require('domain')
var helper = require('./../test-helper')
var Client = require('./../../lib/native')
const suite = new helper.Suite()
suite.test('fires callback with results', function (done) {
var client = new Client(helper.config)
client.connect()
client.query('SELECT 1 as num', assert.calls(function (err, result) {
assert(!err)
assert.equal(result.rows[0].num, 1)
assert.strictEqual(result.rowCount, 1)
client.query('SELECT * FROM person WHERE name = $1', ['Brian'], assert.calls(function (err, result) {
assert(!err)
assert.equal(result.rows[0].name, 'Brian')
client.end(done)
}))
}))
})
suite.test('preserves domain', function (done) {
var dom = domain.create()
dom.run(function () {
var client = new Client(helper.config)
assert.ok(dom === require('domain').active, 'domain is active')
client.connect()
client.query('select 1', function () {
assert.ok(dom === require('domain').active, 'domain is still active')
client.end(done)
})
})
})