Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: catch exception #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ Installation
npm install pow-mongodb-fixtures


Test
------------

use ``nodeunit`` to run unit test

$ npm i
$ ./node_modules/nodeunit/bin/nodeunit test/index.test.js

Changelog
---------

Expand Down
100 changes: 50 additions & 50 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,31 +372,31 @@ exports['clear'] = {
},

'drops the db if collections not specified': function(test) {
async.series([
function(cb) {
loader.clear(cb);
},

function(cb) {
loadCollection('archer', function(err, docs) {
if (err) return cb(err);

test.same(0, docs.length);

cb();
});
},

function(cb) {
loadCollection('southpark', function(err, docs) {
if (err) return cb(err);

test.same(0, docs.length);

cb();
});
}
], test.done);
try {
async.series([
function(cb) {
loader.clear(cb);
},
function(cb) {
loadCollection('archer', function(err, docs) {
if (err) return cb(err);

test.same(0, docs.length);
cb();
});
},
function(cb) {
loadCollection('southpark', function(err, docs) {
if (err) return cb(err);

test.same(0, docs.length);
cb();
});
}
], test.done);
} catch (e) {
test.done(e);
}
},

'clears a collection if called with a string': function(test) {
Expand Down Expand Up @@ -480,31 +480,31 @@ exports['clearAllAndLoad'] = {
{ name: 'Kyle' }
];

async.series([
function(cb) {
loader.clearAllAndLoad(data, cb);
},

function(cb) {
loadCollection('archer', function(err, docs) {
if (err) return cb(err);

test.same(0, docs.length);

cb();
});
},

function(cb) {
loadCollection('southpark', function(err, docs) {
if (err) return cb(err);

test.same(1, docs.length);

cb();
});
}
], test.done);
try {
async.series([
function(cb) {
loader.clearAllAndLoad(data, cb);
},
function(cb) {
loadCollection('archer', function(err, docs) {
if (err) return cb(err);

test.same(0, docs.length);
cb();
});
},
function(cb) {
loadCollection('southpark', function(err, docs) {
if (err) return cb(err);

test.same(1, docs.length);
cb();
});
}
], test.done);
} catch (e) {
test.done(e);
}
}
};

Expand Down