Permalink
Browse files

* Add tests.

  • Loading branch information...
1 parent e71d152 commit b09b7ac9f4390b02aa17038bc29a0013a1b3817c @kcbanner kcbanner committed Apr 14, 2012
Showing with 38 additions and 6 deletions.
  1. +10 −2 Makefile
  2. +3 −1 index.js
  3. +24 −1 test/connect-mongo.test.js
  4. +1 −2 test/mocha.opts
View
@@ -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
@@ -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');
@@ -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
@@ -1,2 +1 @@
---ui exports
---reporter spec
+--ui exports

0 comments on commit b09b7ac

Please sign in to comment.