Testing framework: mocha I want to test saving and then deleting created document in mongodb (with mongoose)
Code that actually do this :
item = new Item()
item.save(function(err, data){
// if no errors test passed, then I need to test removing that item
Item.remove({_id: data.id})
})
How should I describe the test?
I want to have separate tests results for save and remove in output.
Thanks.
var User = require('../../models/user');
describe('User', function(){
describe('#save()', function(){
it('should save without error', function(done){
var user = new User({ username : 'Luna'
, email : 'luna@me.name'
, password : 'asdf123'
});
user.save(function(err){
if (err) throw err;
done();
});
})
})
})