-
Book Overview & Buying
-
Table Of Contents
Mastering Backbone.js
By :
Views manage the relationship between data (such as, models or collections) and the user interactions (DOM). In the case of views, you should test for the following:
Rendering: Given a model or collection, you should verify that the output HTML is the right one
Events: This verifies that the DOM events are handled correctly
Model changes: If the model changes something, the view should be in sync
For this example, we are going to test the ContactForm view; the responsibility of this view is to show a form to the user and then get the user input to update a model.
When making test on views, it is recommended to use a fake model and not the original Contact model. The main reason for this is to isolate the ContactView object so that if a test fails, you will know that the error is isolated in the view and does not depend on the Contact model.
You can start testing whether the rendered HTML is right, as follows:
var Backbone = require('backbone');
var ContactForm = require('../../.....
Change the font size
Change margin width
Change background colour