Skip to content

Commit 0acaf9d

Browse files
authored
Fix compare (#1923)
* Fix deepEqual compare In node 12 assert.deepEqual against a buffer & array no longer passes if the values are the same. This makes sense. Updated the test to not use deepEqual in this case.
1 parent d8a0e1e commit 0acaf9d

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

lib/native/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* README.md file in the root directory of this source tree.
88
*/
99

10-
// eslint-disable-next-line node/no-missing-require
10+
// eslint-disable-next-line
1111
var Native = require('pg-native')
1212
var TypeOverrides = require('../type-overrides')
1313
var semver = require('semver')

test/unit/utils-tests.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ test('EventEmitter.once', function (t) {
2929

3030
test('normalizing query configs', function () {
3131
var config
32-
var callback = function () {}
32+
var callback = function () { }
3333

34-
config = utils.normalizeQueryConfig({text: 'TEXT'})
35-
assert.same(config, {text: 'TEXT'})
34+
config = utils.normalizeQueryConfig({ text: 'TEXT' })
35+
assert.same(config, { text: 'TEXT' })
3636

37-
config = utils.normalizeQueryConfig({text: 'TEXT'}, [10])
38-
assert.deepEqual(config, {text: 'TEXT', values: [10]})
37+
config = utils.normalizeQueryConfig({ text: 'TEXT' }, [10])
38+
assert.deepEqual(config, { text: 'TEXT', values: [10] })
3939

40-
config = utils.normalizeQueryConfig({text: 'TEXT', values: [10]})
41-
assert.deepEqual(config, {text: 'TEXT', values: [10]})
40+
config = utils.normalizeQueryConfig({ text: 'TEXT', values: [10] })
41+
assert.deepEqual(config, { text: 'TEXT', values: [10] })
4242

4343
config = utils.normalizeQueryConfig('TEXT', [10], callback)
44-
assert.deepEqual(config, {text: 'TEXT', values: [10], callback: callback})
44+
assert.deepEqual(config, { text: 'TEXT', values: [10], callback: callback })
4545

46-
config = utils.normalizeQueryConfig({text: 'TEXT', values: [10]}, callback)
47-
assert.deepEqual(config, {text: 'TEXT', values: [10], callback: callback})
46+
config = utils.normalizeQueryConfig({ text: 'TEXT', values: [10] }, callback)
47+
assert.deepEqual(config, { text: 'TEXT', values: [10], callback: callback })
4848
})
4949

5050
test('prepareValues: buffer prepared properly', function () {
@@ -57,7 +57,8 @@ test('prepareValues: Uint8Array prepared properly', function () {
5757
var buf = new Uint8Array([1, 2, 3]).subarray(1, 2)
5858
var out = utils.prepareValue(buf)
5959
assert.ok(Buffer.isBuffer(out))
60-
assert.deepEqual(out, [2])
60+
assert.equal(out.length, 1)
61+
assert.deepEqual(out[0], 2)
6162
})
6263

6364
test('prepareValues: date prepared properly', function () {
@@ -167,12 +168,12 @@ test('prepareValue: objects with simple toPostgres prepared properly', function
167168
assert.strictEqual(out, 'zomgcustom!')
168169
})
169170

170-
test('prepareValue: buffer array prepared properly', function() {
171-
var buffer1 = Buffer.from('dead', 'hex')
172-
var buffer2 = Buffer.from('beef', 'hex')
173-
var out = utils.prepareValue([buffer1, buffer2])
174-
assert.strictEqual(out, '{\\\\xdead,\\\\xbeef}')
175-
})
171+
test('prepareValue: buffer array prepared properly', function () {
172+
var buffer1 = Buffer.from('dead', 'hex')
173+
var buffer2 = Buffer.from('beef', 'hex')
174+
var out = utils.prepareValue([buffer1, buffer2])
175+
assert.strictEqual(out, '{\\\\xdead,\\\\xbeef}')
176+
})
176177

177178
test('prepareValue: objects with complex toPostgres prepared properly', function () {
178179
var buf = Buffer.from('zomgcustom!')

0 commit comments

Comments
 (0)