Permalink
Browse files

test: make notes about equality check issues

  • Loading branch information...
1 parent 2ef39cf commit 659f2111a7149d9d49812db02d3bac6a85d413b7 @vkarpov15 vkarpov15 committed Aug 31, 2016
Showing with 21 additions and 7 deletions.
  1. +1 −1 format_deps.js
  2. +1 −2 package.json
  3. +19 −4 test/model.findOneAndUpdate.test.js
View
@@ -1,5 +1,5 @@
var p = require('./package.json');
-var _ = require('underscore');
+var _ = require('lodash');
var result = _.map(p.browserDependencies, function(v, k) {
return k + '@' + v;
View
@@ -20,7 +20,7 @@
"license": "MIT",
"dependencies": {
"async": "1.5.2",
- "bson": "~0.4.23",
+ "bson": "~0.5.4",
"hooks-fixed": "1.2.0",
"kareem": "1.1.3",
"mongodb": "2.2.9",
@@ -52,7 +52,6 @@
"q": "1.4.1",
"tbd": "0.6.4",
"uglify-js": "2.7.0",
- "underscore": "1.8.3",
"validator": "5.4.0"
},
"browserDependencies": {
@@ -11,7 +11,7 @@ var Utils = require('../lib/utils');
var Schema = mongoose.Schema;
var ObjectId = Schema.Types.ObjectId;
var DocumentObjectId = mongoose.Types.ObjectId;
-var _ = require('underscore');
+var _ = require('lodash');
/**
* Setup.
@@ -909,7 +909,7 @@ describe('model: findByIdAndUpdate:', function() {
});
});
- it('can do deep equals on object id after findOneAndUpdate (gh-2070)', function(done) {
+ it.only('can do deep equals on object id after findOneAndUpdate (gh-2070)', function(done) {
var db = start();
var accountSchema = new Schema({
@@ -936,17 +936,32 @@ describe('model: findByIdAndUpdate:', function() {
function(error, doc) {
assert.ifError(error);
assert.ok(Utils.deepEqual(doc.contacts[0].account, a2._id));
- assert.ok(_.isEqual(doc.contacts[0].account, a2._id));
+ assert.ok(_.isEqualWith(doc.contacts[0].account, a2._id, compareBuffers));
+ // Re: commends on https://github.com/mongodb/js-bson/commit/aa0b54597a0af28cce3530d2144af708e4b66bf0
+ // Deep equality checks no longer work as expected with node 0.10.
+ // Please file an issue if this is a problem for you
+ if (!/^v0.10.\d+$/.test(process.version)) {
+ assert.ok(_.isEqual(doc.contacts[0].account, a2._id));
+ }
Account.findOne({name: 'parent'}, function(error, doc) {
assert.ifError(error);
assert.ok(Utils.deepEqual(doc.contacts[0].account, a2._id));
- assert.ok(_.isEqual(doc.contacts[0].account, a2._id));
+ assert.ok(_.isEqualWith(doc.contacts[0].account, a2._id, compareBuffers));
+ if (!/^v0.10.\d+$/.test(process.version)) {
+ assert.ok(_.isEqual(doc.contacts[0].account, a2._id));
+ }
db.close(done);
});
});
});
});
+
+ function compareBuffers(a, b) {
+ if (Buffer.isBuffer(a) && Buffer.isBuffer(b)) {
+ return a.toString('hex') === b.toString('hex')
+ }
+ }
});
it('adds __v on upsert (gh-2122)', function(done) {

0 comments on commit 659f211

Please sign in to comment.