Skip to content

Commit

Permalink
* Add tests to increase coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
kcbanner committed Apr 14, 2012
1 parent b09b7ac commit 535dae5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/connect-mongo.js
Expand Up @@ -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 {
Expand Down
23 changes: 23 additions & 0 deletions test/connect-mongo.test.js
Expand Up @@ -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';
Expand Down Expand Up @@ -198,3 +220,4 @@ exports.test_clear_expired = function(done) {
});
});
};

0 comments on commit 535dae5

Please sign in to comment.