logging.js 511 B

123456789101112131415161718192021
  1. const expect = require('expect.js')
  2. const describe = require('mocha').describe
  3. const it = require('mocha').it
  4. const Pool = require('../')
  5. describe('logging', function () {
  6. it('logs to supplied log function if given', function () {
  7. const messages = []
  8. const log = function (msg) {
  9. messages.push(msg)
  10. }
  11. const pool = new Pool({ log: log })
  12. return pool.query('SELECT NOW()').then(function () {
  13. expect(messages.length).to.be.greaterThan(0)
  14. return pool.end()
  15. })
  16. })
  17. })