When I run my tests (I am using Mocha, Chai and Sinon) for a backbone model which extends from another backbone model, I get an error:
TypeError: 'undefined' is not an object (evaluating 'Model._entity')
I thought that by instantiating Model._entity that this error would go away, but it doesn't. Should I be using a stub instead?
I've searched the web for an answer but all the examples are for models that extend directly from Backbone and not another model.
What do I need to do to avoid this error?
My test code:
describe("Model.address", function () {
beforeEach(function () {
// build up a fake server
this.server = sinon.fakeServer.create();
this.server.autoRespond = true;
this.parentModel = new Model._entity();
this.Model_address = new Model.Address();
});
afterEach(function () {
// delete fake server
this.server.restore();
});
describe("Defaults", function () {
// test defaults
it("has default values", function () {
// create empty model
var model = this.Model_address;
// expect model to be truthy
expect(model).to.be.ok;
});
});
});
Aucun commentaire:
Enregistrer un commentaire