Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Add tests to increase coverage.

  • Loading branch information...
commit 535dae501b2e1efd69224d4c25aa7a7cf1ed4d5d 1 parent b09b7ac
@kcbanner authored
Showing with 24 additions and 2 deletions.
  1. +1 −2  lib/connect-mongo.js
  2. +23 −0 test/connect-mongo.test.js
View
3  lib/connect-mongo.js
@@ -89,8 +89,7 @@ module.exports = function(connect) {
this.db_collection_name = options.collection || defaultOptions.collection;
-
- if ((typeof options.stringify!="undefined")?options.stringify:defaultOptions.stringify) {
+ if (options.hasOwnProperty('stringify') ? options.stringify : defaultOptions.stringify) {
this._serialize_session = JSON.stringify;
this._unserialize_session = JSON.parse;
} else {
View
23 test/connect-mongo.test.js
@@ -58,6 +58,28 @@ exports.test_set = function(done) {
});
};
+exports.test_set_no_stringify = function(done) {
+ open_db({db: options.db, stringify: false}, function(store, db, collection) {
+ var sid = 'test_set-sid';
+ store.set(sid, {foo: 'bar'}, function(err, session) {
+ assert.strictEqual(err, null);
+
+ // Verify it was saved
+ collection.findOne({_id: sid}, function(err, session) {
+ assert.deepEqual(session,
+ {
+ session: {foo: 'bar'},
+ _id: sid
+ });
+
+ cleanup(store, db, collection, function() {
+ done();
+ });
+ });
+ });
+ });
+};
+
exports.test_set_expires = function(done) {
open_db(options, function(store, db, collection) {
var sid = 'test_set_expires-sid';
@@ -198,3 +220,4 @@ exports.test_clear_expired = function(done) {
});
});
};
+
Please sign in to comment.
Something went wrong with that request. Please try again.