node-postgres/test/integration/client/query-as-promise-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

34 lines
861 B
JavaScript

'use strict'
var helper = require(__dirname + '/../test-helper')
var pg = helper.pg
process.on('unhandledRejection', function (e) {
console.error(e, e.stack)
process.exit(1)
})
const pool = new pg.Pool()
const suite = new helper.Suite()
suite.test('promise API', (cb) => {
pool.connect().then((client) => {
client.query('SELECT $1::text as name', ['foo'])
.then(function (result) {
assert.equal(result.rows[0].name, 'foo')
return client
})
.then(function (client) {
client.query('ALKJSDF')
.catch(function (e) {
assert(e instanceof Error)
client.query('SELECT 1 as num')
.then(function (result) {
assert.equal(result.rows[0].num, 1)
client.release()
pool.end(cb)
})
})
})
})
})