diff options
author | 2020-11-18 23:26:45 +0100 | |
---|---|---|
committer | 2020-11-18 23:26:45 +0100 | |
commit | 81ddf9b700bc48a1f8e472209f080f9c1d9a9b09 (patch) | |
tree | 8b959d50c5a614cbf9fcb346ed556140374d4b6d /node_modules/mquery/test/utils.test.js | |
parent | 1870f3fdf43707a15fda0f609a021f516f45eb63 (diff) | |
download | website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.gz website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.bz2 website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.zip |
rm node_modules
Diffstat (limited to 'node_modules/mquery/test/utils.test.js')
-rw-r--r-- | node_modules/mquery/test/utils.test.js | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/node_modules/mquery/test/utils.test.js b/node_modules/mquery/test/utils.test.js deleted file mode 100644 index ff95f33..0000000 --- a/node_modules/mquery/test/utils.test.js +++ /dev/null @@ -1,144 +0,0 @@ -'use strict'; - -var Buffer = require('safe-buffer').Buffer; -var utils = require('../lib/utils'); -var assert = require('assert'); -var debug = require('debug'); - -var mongo; -try { - mongo = new require('mongodb'); -} catch (e) { - debug('mongo', 'cannot construct mongodb instance'); -} - -describe('lib/utils', function() { - describe('clone', function() { - it('clones constructors named ObjectId', function(done) { - function ObjectId(id) { - this.id = id; - } - - var o1 = new ObjectId('1234'); - var o2 = utils.clone(o1); - assert.ok(o2 instanceof ObjectId); - - done(); - }); - - it('clones constructors named ObjectID', function(done) { - function ObjectID(id) { - this.id = id; - } - - var o1 = new ObjectID('1234'); - var o2 = utils.clone(o1); - - assert.ok(o2 instanceof ObjectID); - done(); - }); - - 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) { - function ObjectID(id) { - this.id = id; - this.cloned = false; - } - - ObjectID.prototype.clone = function() { - var ret = new ObjectID(this.id); - ret.cloned = true; - return ret; - }; - - var id = 1234; - var o1 = new ObjectID(id); - assert.equal(id, o1.id); - assert.equal(false, o1.cloned); - - var o2 = utils.clone(o1); - assert.ok(o2 instanceof ObjectID); - assert.equal(id, o2.id); - assert.ok(o2.cloned); - done(); - }); - - it('clones mongodb.ReadPreferences', function(done) { - if (!mongo) return done(); - - var tags = [ - {dc: 'tag1'} - ]; - var prefs = [ - new mongo.ReadPreference('primary'), - new mongo.ReadPreference(mongo.ReadPreference.PRIMARY_PREFERRED), - new mongo.ReadPreference('secondary', tags) - ]; - - var prefsCloned = utils.clone(prefs); - - for (var i = 0; i < prefsCloned.length; i++) { - assert.notEqual(prefs[i], prefsCloned[i]); - 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('clones mongodb.Binary', function(done) { - if (!mongo) return done(); - var buf = Buffer.from('hi'); - var binary = new mongo.Binary(buf, 2); - var clone = utils.clone(binary); - assert.equal(binary.sub_type, clone.sub_type); - assert.equal(String(binary.buffer), String(buf)); - assert.ok(binary !== clone); - done(); - }); - - it('handles objects with no constructor', function(done) { - var name = '335'; - - var o = Object.create(null); - o.name = name; - - var clone; - assert.doesNotThrow(function() { - clone = utils.clone(o); - }); - - assert.equal(name, clone.name); - assert.ok(o != clone); - done(); - }); - - it('handles buffers', function(done) { - var buff = Buffer.alloc(10); - buff.fill(1); - var clone = utils.clone(buff); - - for (var i = 0; i < buff.length; i++) { - assert.equal(buff[i], clone[i]); - } - - done(); - }); - }); -}); |