Skip to content

Commit

Permalink
Complete all functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maythee Anegboonlap committed Nov 29, 2011
1 parent 08390ca commit 4342fe0
Showing 1 changed file with 145 additions and 0 deletions.
145 changes: 145 additions & 0 deletions test/FunctionalTestMongoModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,5 +451,150 @@ testit('TestMongoModel', {
require['get with invalid key'] = true;
test.assert(!output);
});
},

'test remove with valid key': function (test) {
var collections;
var model;

var done = false;
var output = null;

step(
function begin () {
test.waitFor(
function () {
return require['get with invalid key'];
}, this)
},
function logic () {
collections = local.collections;
model = local.model;

model.remove(fixtures[0]._id, this);
},
function removed (error) {
collections.count(this);
},
function count (error, total) {
output = total;
done = true;
});

test.waitFor(
function (time) {
return done;
},
function () {
require['remove with valid key'] = true;
test.assertEqual(31, output);
});
},

'test remove with invalid key': function (test) {
var collections;
var model;

var done = false;
var output = null;

step(
function begin () {
test.waitFor(
function () {
return require['remove with valid key'];
}, this)
},
function logic () {
collections = local.collections;
model = local.model;

model.remove(fixtures[0]._id, this);
},
function removed (error) {
collections.count(this);
},
function count (error, total) {
output = total;
done = true;
});

test.waitFor(
function (time) {
return done;
},
function () {
require['remove with invalid key'] = true;
test.assertEqual(31, output);
});
},

'test exists on valid key': function (test) {
var model;

var done = false;
var output = null;

step(
function begin () {
test.waitFor(
function () {
return require['remove with invalid key'];
}, this)
},
function logic () {
collections = local.collections;
model = local.model;

model.exists(fixtures[1]._id, this);
},
function validate (error, exists) {
output = exists;
done = true;
});

test.waitFor(
function (time) {
return done;
},
function () {
require['exists on valid key'] = true;
test.assert(output);
});
},

'test exists on invalid key': function (test) {
var model;

var done = false;
var output = null;
var success = false;

step(
function begin () {
test.waitFor(
function () {
return require['exists on valid key'];
}, this)
},
function logic () {
collections = local.collections;
model = local.model;

model.exists(fixtures[0]._id, this);
},
function validate (error, exists) {
output = exists;
done = true;
});

test.waitFor(
function (time) {
return done;
},
function () {
require['exists on invalid key'] = true;
test.assert(!output);
});
}
});

0 comments on commit 4342fe0

Please sign in to comment.