-
Book Overview & Buying
-
Table Of Contents
Backbone.js Patterns and Best Practices
By :
QUnit (http://qunitjs.com), a lightweight unit testing framework maintained by the jQuery team, which is quite easy to work with compared to other frameworks. Discussing QUnit in complete detail is beyond the scope of this book, but we will learn about the simple features of it and explore how we can use it with our Backbone components.
Assertions are the most essential elements of any unit test framework. You need to compare your actual implementation values to the results that the test produces. Assertions are the methods that serve this comparison functionality. QUnit has only eight assertions; we are going to use some of them in the next section. Let's discuss a few of them here:
ok (state, message): This passes if the first argument is true
equal (actual, expected, message): This returns true if actual and expected are equal
deepEqual (actual, expected, message): This is a deep recursive-comparison assertion, working on primitive types, arrays, objects, regular expressions...
Change the font size
Change margin width
Change background colour