Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Add tests.

  • Loading branch information...
commit b09b7ac9f4390b02aa17038bc29a0013a1b3817c 1 parent e71d152
@kcbanner authored
View
12 Makefile
@@ -1,5 +1,13 @@
+REPORTER = spec
+
test:
- @mocha
+ @mocha --reporter $(REPORTER)
+
+test-cov: lib-cov
+ @CONNECT_MONGO_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html
+
+lib-cov:
+ @jscoverage lib lib-cov
-.PHONY: test
+.PHONY: test test-cov
View
4 index.js
@@ -1,2 +1,4 @@
-module.exports = require('./lib/connect-mongo');
+module.exports = process.env.CONNECT_MONGO_COV
+ ? require('./lib-cov/connect-mongo')
+ : require('./lib/connect-mongo');
View
25 test/connect-mongo.test.js
@@ -159,6 +159,29 @@ exports.test_options_url = function(done) {
});
};
+exports.test_options_url_auth = function(done) {
+ var store = new MongoStore({
+ url: 'mongodb://test:test@127.0.0.1:27017/connect-mongo-test/sessions-test'
+ }, function() {
+ assert.strictEqual(store.db.databaseName, 'connect-mongo-test');
+ assert.strictEqual(store.db.serverConfig.host, '127.0.0.1');
+ assert.equal(store.db.serverConfig.port, 27017);
+ assert.equal(store.collection.collectionName, 'sessions-test');
+ cleanup_store(store);
+ done();
+ });
+};
+
+exports.test_options_no_db = function(done) {
+ assert.throws(
+ function() {
+ var store = new MongoStore({}, function() {});
+ },
+ Error);
+
+ done();
+};
+
exports.test_clear_expired = function(done) {
open_db({db: options.db, clear_interval: 0.1}, function(store, db, collection) {
var sid = 'test_clear_expired-sid';
@@ -174,4 +197,4 @@ exports.test_clear_expired = function(done) {
}, 150);
});
});
-};
+};
View
3  test/mocha.opts
@@ -1,2 +1 @@
---ui exports
---reporter spec
+--ui exports
Please sign in to comment.
Something went wrong with that request. Please try again.