Browse Source
so we can have the collections passed in the call to mongojs.saintedlama/travis-non-legacy
Eduardo Sorribas
10 years ago
4 changed files with 37 additions and 30 deletions
@ -1,33 +1,39 @@ |
|||
var test = require('tape'); |
|||
var mongodb = require('mongodb'); |
|||
var mongojs = require('../'); |
|||
var each = require('each-series'); |
|||
|
|||
test('receive a driver db instance', function(t) { |
|||
test('receive a driver db or mongojs instance', function(t) { |
|||
mongodb.Db.connect('mongodb://localhost/test', function(err, thedb) { |
|||
var db = mongojs(thedb, ['a']); |
|||
|
|||
var afterFind = function() { |
|||
db.a.remove(function(err) { |
|||
t.ok(!err); |
|||
t.equal(db.toString(), 'test'); |
|||
t.end(); |
|||
}); |
|||
}; |
|||
var doTests = function(db, callback) { |
|||
var afterFind = function() { |
|||
db.a.remove(function(err) { |
|||
t.ok(!err); |
|||
t.equal(db.toString(), 'test'); |
|||
callback(); |
|||
}); |
|||
}; |
|||
|
|||
var afterInsert = function(err) { |
|||
t.ok(!err); |
|||
var afterInsert = function(err) { |
|||
t.ok(!err); |
|||
|
|||
db.a.findOne(function(err, data) { |
|||
t.equal(data.name, 'Pidgey'); |
|||
afterFind(); |
|||
}); |
|||
}; |
|||
db.a.findOne(function(err, data) { |
|||
t.equal(data.name, 'Pidgey'); |
|||
afterFind(); |
|||
}); |
|||
}; |
|||
|
|||
var afterRemove = function(err) { |
|||
t.ok(!err); |
|||
db.a.insert({name: 'Pidgey'}, afterInsert); |
|||
var afterRemove = function(err) { |
|||
t.ok(!err); |
|||
db.a.insert({name: 'Pidgey'}, afterInsert); |
|||
|
|||
}; |
|||
db.a.remove(afterRemove); |
|||
}; |
|||
db.a.remove(afterRemove); |
|||
|
|||
each([mongojs(thedb, ['a']), mongojs(mongojs('test', []), ['a'])], function(db, i, cb) { |
|||
doTests(db, cb); |
|||
}, t.end.bind(t)); |
|||
}); |
|||
}); |
|||
|
@ -1,9 +0,0 @@ |
|||
var test = require('tape'); |
|||
var mongojs = require('../'); |
|||
var db = mongojs('test'); |
|||
|
|||
test('receive a driver db instance', function(t) { |
|||
var thedb = mongojs(db); |
|||
t.ok(db === thedb); |
|||
t.end(); |
|||
}); |
Loading…
Reference in new issue