Mocha.js: how to test consequent save and delete with mongoose

Problem

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.

Problem courtesy of: WHITECOLOR

Solution

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();
      });
    })
  })
})
Solution courtesy of: chovy

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.