Comparing version 0.5.1 to 0.5.2
0.5.2 / 2014-01-30 | ||
================== | ||
* fixed; cloning ObjectId constructors | ||
* fixed; cloning of ReadPreferences #30 [ashtuchkin](https://github.com/ashtuchkin) | ||
* tests; use specific mongodb version #29 [AvianFlu](https://github.com/AvianFlu) | ||
* tests; remove dependency on ObjectId #28 [refack](https://github.com/refack) | ||
* tests; add failing ReadPref test | ||
0.5.1 / 2014-01-17 | ||
@@ -3,0 +12,0 @@ ================== |
@@ -26,3 +26,3 @@ 'use strict'; | ||
if (obj.constructor) { | ||
if (/ObjectI[dD]{1}/.test(obj.constructor.name)) { | ||
if (/ObjectI[dD]$/.test(obj.constructor.name)) { | ||
return 'function' == typeof obj.clone | ||
@@ -33,2 +33,5 @@ ? obj.clone() | ||
if ('ReadPreference' === obj._type && obj.isValid && obj.toObject) | ||
return new obj.constructor(obj.mode, clone(obj.tags, options)); | ||
if ('Date' === obj.constructor.name || 'Function' === obj.constructor.name) | ||
@@ -35,0 +38,0 @@ return new obj.constructor(+obj); |
{ | ||
"name": "mquery", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "Expressive query building for MongoDB", | ||
@@ -19,3 +19,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mongodb": "1.3.x", | ||
"mongodb": "1.3.23", | ||
"mocha": "1.9.x" | ||
@@ -22,0 +22,0 @@ }, |
var utils = require('../lib/utils'); | ||
var assert = require('assert'); | ||
var mongo = require('mongodb'); | ||
@@ -31,2 +32,14 @@ describe('lib/utils', function() { | ||
it('does not clone constructors named ObjectIdd', function(done) { | ||
function ObjectIdd (id) { | ||
this.id = id; | ||
} | ||
var o1 = new ObjectIdd('1234'); | ||
var o2 = utils.clone(o1); | ||
assert.ok(!(o2 instanceof ObjectIdd)); | ||
done(); | ||
}); | ||
it('optionally clones ObjectId constructors using its clone method', function(done) { | ||
@@ -56,2 +69,29 @@ function ObjectID (id) { | ||
it('clones mongodb.ReadPreferences', function(done) { | ||
var tags = [{dc: 'tag1'}]; | ||
var prefs = [ | ||
new mongo.ReadPreference("primary"), | ||
new mongo.ReadPreference(mongo.ReadPreference.PRIMARY_PREFERRED), | ||
new mongo.ReadPreference("primary", tags), | ||
mongo.ReadPreference("primary", tags) | ||
]; | ||
var prefsCloned = utils.clone(prefs); | ||
for (var i = 0; i < prefsCloned.length; i++) { | ||
assert.notEqual(prefs[i], prefsCloned[i]); | ||
assert.ok(prefsCloned[i] instanceof mongo.ReadPreference); | ||
assert.ok(prefsCloned[i].isValid()); | ||
if (prefs[i].tags) { | ||
assert.ok(prefsCloned[i].tags); | ||
assert.notEqual(prefs[i].tags, prefsCloned[i].tags); | ||
assert.notEqual(prefs[i].tags[0], prefsCloned[i].tags[0]); | ||
} else { | ||
assert.equal(prefsCloned[i].tags, null); | ||
} | ||
} | ||
done(); | ||
}); | ||
it('handles objects with no constructor', function(done) { | ||
@@ -58,0 +98,0 @@ var name ='335'; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
191725
5064