mardi 20 juin 2017

stub of .save() returns nothing and times out

I have the function add in my controller in promise, and in my model has a .pre() (which seems to me the origin of the problem) that is called before the .save() I no have idea what is happens, someone can help me ??

Testing:

describe('NaturalController', function() {
      var stubSave,
      naturalController = new NaturalController();

      context('#add', function() {

        beforeEach(function() {
          stubSave = sinon.stub(NaturalPersonModel.prototype, "save");
        });

        afterEach(function() {
          stubSave.restore();
        });

        it('resolve when user is new', function() {
          stubSave.returns(Bluebird.resolve(naturalPersonFixture.save));
          chai.expect(naturalController.add(naturalPersonFixture.add)).to.eventually.equal(naturalPersonFixture.save);
        });
    });

Aucun commentaire:

Enregistrer un commentaire