aboutsummaryrefslogtreecommitdiff
path: root/node_modules/mongo-factory/test/test.js
diff options
context:
space:
mode:
authorKumar Damani <kumar.damani@mail.utoronto.ca>2019-04-16 13:17:06 +0000
committerKumar Damani <kumar.damani@mail.utoronto.ca>2019-04-16 13:17:06 +0000
commitdc46b87abee1e441c07524ddde67fd902a919336 (patch)
tree13eba08b8655dfd78e9600ec5f612011a0bf3b35 /node_modules/mongo-factory/test/test.js
parent26f4b38e9e5a202756a7c33abc775aea2617aeaf (diff)
added some dependencies to package.json
Diffstat (limited to 'node_modules/mongo-factory/test/test.js')
-rw-r--r--node_modules/mongo-factory/test/test.js94
1 files changed, 0 insertions, 94 deletions
diff --git a/node_modules/mongo-factory/test/test.js b/node_modules/mongo-factory/test/test.js
deleted file mode 100644
index 9ac91c3..0000000
--- a/node_modules/mongo-factory/test/test.js
+++ /dev/null
@@ -1,94 +0,0 @@
-var chai = require('chai');
-var expect = chai.expect;
-var mongo = require('mongodb');
-
-describe('mongoFactory', function() {
- var mongoFactory;
-
- beforeEach(function() {
- mongoFactory = require('../');
- });
-
- it('can be required without blowing up', function(done) {
- var mongoFactory = require('../');
- expect(mongoFactory).to.exist;
- done();
- });
-
- describe('getConnection()', function() {
- describe('with no parameters', function() {
- it('should fulfill the promise', function(done) {
- var conn = mongoFactory.getConnection();
- expect(conn).to.be.fulfilled;
- done();
- });
-
- it('should reject the promise', function(done) {
- var conn = mongoFactory.getConnection();
- expect(conn).to.be.rejected;
- done();
- });
- });
-
- describe('with a null parameter', function() {
- it('should reject the promise', function(done) {
- var conn = mongoFactory.getConnection(null);
- expect(conn).to.be.rejected;
- done();
- });
- });
-
- describe('with a valid mongo string parameter', function() {
- describe('needing to create the pool the first time', function() {
- it('should return a fulfilled promise', function(done) {
- var conn = mongoFactory.getConnection('mongodb://localhost:27017').then(function(db) {
- expect(conn).to.be.fulfilled;
- expect(conn).to.not.be.rejected;
- done();
- });
- });
- });
-
- describe('after a pool is already instantiated', function() {
- it('should return a fulfilled promise', function(done) {
- var conn1 = mongoFactory.getConnection('mongodb://localhost:27017').then(function() {
- var conn = mongoFactory.getConnection('mongodb://localhost:27017').then(function() {
- expect(conn).to.be.fulfilled;
- expect(conn).to.not.be.rejected;
- done();
- });
- });
- });
- });
- });
- });
-
- describe('ObjectID', function() {
- it('should return mongo\'s ObjectID method', function() {
- var oid = mongoFactory.ObjectID;
- expect(oid).to.be.a.function;
- });
-
- it('should allow you to create a new ObjectID', function() {
- var oid = new mongoFactory.ObjectID;
- expect(oid.toHexString().length).to.equal(24);
- });
-
- it('should allow you to compare ObjectIDs', function() {
- var oid1 = new mongoFactory.ObjectID;
- var oid2 = new mongoFactory.ObjectID(oid1.id);
- var oid3 = new mongoFactory.ObjectID;
- expect(oid1.equals(oid2));
- expect(!oid1.equals(oid3));
- });
-
- it('should allow you to create a new ObjectID with a specific timestamp', function() {
- // Get a timestamp in seconds
- var timestamp = Math.floor(new Date().getTime()/1000);
- // Create a date with the timestamp
- var timestampDate = new Date(timestamp*1000);
- var oid = new mongoFactory.ObjectID(timestamp);
- expect(oid.getTimestamp().toString()).to.equal(timestampDate.toString());
- });
- });
-});