3 ms·
I think you need to read the post again. In the first example, he: - initializes a view - asks the collection to fetch itself - asserts that the VIEW no
by mobmad 14y ago
I think you need to read the post again.
In the first example, he:
- initializes a view
- asks the collection to fetch itself
- asserts that the VIEW now has 20 person elements, not the collection.
What this first test does is asserting that the "PersonsView" and its event binding and logic is setup correctly.
The same applies for the second example where PersonsView is the object under test. In this example he asserts that an ".errors" element exists in the view if the ajax request fails. I.e. that view logic and event binding for error handling is setup correctly.
Both cases test custom code in PersonsView. The tests would probably fail if PersonsView->initialize or PersonsView->render didn't behave correctly. As far I can tell, no code test Backbone in itself.