help please write a test for backbone / jasmine
there is a model:
window.APP = window.APP || {}; APP.CalcModel = Backbone.Model.extend({ defaults: { errDepartCity: [], errDestinCity: [], errShippOptionsWeight: [], errShippOptionsVolume: [] } }); In this model there is a method that clears the properties. For now, to simplify the task, I would like to initialize the model with data and check empty fields or not. here is my test:
describe("fill model check", function() { it("should errDepartCity is not empty after init", function() { var model = new APP.CalcModel({ errDepartCity: ['qwerty', 'asdfgh'], errDestinCity: ['qwerty', 'asdfgh'], errShippOptionsWeight: ['qwerty', 'asdfgh'], errShippOptionsVolume: ['qwerty', 'asdfgh'] }); // console.log(model); expect(model.get('errDepartCity').length).toEqual(0); }); }); the problem is that it passes successfully. although it should not because the length of the array is not zero. I do not understand why
using not.toEqual instead of .toEqual changes nothing - the test passes successfully
APP.CalcModel? If yes, then the problem is really in reference types indefaultsas @AriesUa says - Dmitriy Simushev