Testing models and collections
The most basic test is to ensure that models and collections have the right properties set in order to prevent accidental changes in its properties. In the case of models, you can test the default values when a new contact is created and verify that the url
attribute is right:
// spec/apps/contacts/models/contactSpec.js var Contact = require('../../../../app/js/apps/contacts/models/contact'); describe('Contact model', () => { describe('creating a new contact', () => { it('has the default values', () => { var contact = new Contact(); expect(contact.get('name')).toEqual(''); expect(contact.get('phone')).toEqual(''); expect(contact.get('email')).toEqual(''); expect(contact.get('address1')).toEqual(''); expect(contact.get('address2')).toEqual(''); expect(contact.get('avatar')).toEqual(null); }); }); it('has the rigthurl', () => { var contact = new Contact(); expect(contact.url()).toEqual('/api/contacts'); }); });
For collections, you can verify...