UNPKG

837 BJavaScriptView Raw
1const expect = require('expect.js')
2const describe = require('mocha').describe
3const it = require('mocha').it
4const Pool = require('../')
5
6describe('Connection strings', function () {
7 it('pool delegates connectionString property to client', function (done) {
8 const connectionString = 'postgres://foo:bar@baz:1234/xur'
9
10 const pool = new Pool({
11 // use a fake client so we can check we're passed the connectionString
12 Client: function (args) {
13 expect(args.connectionString).to.equal(connectionString)
14 return {
15 connect: function (cb) {
16 cb(new Error('testing'))
17 },
18 on: function () {},
19 }
20 },
21 connectionString: connectionString,
22 })
23
24 pool.connect(function (err, client) {
25 expect(err).to.not.be(undefined)
26 done()
27 })
28 })
29})