-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path1382-tests.js
34 lines (31 loc) · 875 Bytes
/
1382-tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"use strict"
var helper = require('./../test-helper')
const suite = new helper.Suite()
suite.test('calling end during active query should return a promise', (done) => {
const client = new helper.pg.Client()
let callCount = 0
// ensure both the query rejects and the end promise resolves
const after = () => {
if (++callCount > 1) {
done()
}
}
client.connect().then(() => {
client.query('SELECT NOW()').catch(after)
client.end().then(after)
})
})
suite.test('calling end during an active query should call end callback', (done) => {
const client = new helper.pg.Client()
let callCount = 0
// ensure both the query rejects and the end callback fires
const after = () => {
if (++callCount > 1) {
done()
}
}
client.connect().then(() => {
client.query('SELECT NOW()').catch(after)
client.end(after)
})
})