Skip to content

Commit

Permalink
fix #16
Browse files Browse the repository at this point in the history
  • Loading branch information
junosuarez committed Jun 9, 2014
1 parent 7a3e4a8 commit d83cc34
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mongodb.js
Expand Up @@ -34,7 +34,7 @@ proto.getCollectionNames = function () {
return this.db.then(function (db) {
return invoke(db, 'collectionNames').then(function (names) {
return names.map(function (name) {
return name.name.replace(/^\w*\./, '')
return name.name.replace(/^[^\.]*\./, '')
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "minq",
"version": "1.0.0-pre7",
"version": "1.0.0-pre8",
"description": "fluent queries for mongodb using Promises/A+",
"keywords": [
"mongodb",
Expand All @@ -26,7 +26,7 @@
"chai-interface": "~1.1.0",
"sinon-chai": "~2.4.0",
"mocha": "~1.8.1",
"moquire": "~1.5.4"
"moquire": "^1.5.5"
},
"dependencies": {
"through": "~2.3.4",
Expand Down
17 changes: 17 additions & 0 deletions test/mongodb.test.js
Expand Up @@ -119,6 +119,23 @@ describe('MongoDb', function () {
})
.then(done, done)
})
it('removes db namespacing from underlying response for dbs including non alpha chars', function (done) {
// https://github.com/jden/minq/issues/16
var MongoDb = moquire('../mongodb')
var db = {
collectionNames: function (callback) {
process.nextTick(function () {
// the mongodb driver sends back funny shaped objects:
callback(null, [{name:'test-db.foos'},{name:'test-db.bars'}])
})
}
}
var mongodb = new MongoDb(db)
mongodb.getCollectionNames().then(function (collectionNames) {
collectionNames.should.deep.equal(['foos','bars'])
})
.then(done, done)
})
})

describe('#dropCollection', function () {
Expand Down

0 comments on commit d83cc34

Please sign in to comment.