-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Review chapter 12 - QUnit #348
Comments
Adding my review comments for Chapter 12 - QUnit and Chapter 13 - SinonJS here: Chapter 12 - QUnitSection: Fixtures ExampleThe enumerate function defined in the example acts as a getter when called with no arguments and the template does not contain enumeration values, so wouldn't the expected value be zero? Section: Asynchronous CodeWhy won't the test hang if the success callback is never called (and thus
Chapter 13 - SinonJSSection: Stubs
Section: MocksExample needs description explaining what is going on in it. Section: ExerciseThe question-style comments with Hint references linking to Backbone documentation in the examples are inconsistent with the comment style in the rest of the book and the questions raised are answered within the book. Would recommend re-writing them as normal comments. Section: Models
Section: CollectionsThese tests seem to be exercising Backbone functionality and not application logic. I would expect tests for the done(), remaining(), nextOrder(), and comparator() functions here. Section: Views
Section: EventThese appear to be tests of the Backbone.Event implementation. Are there instances in which Backbone users would need to write event-related unit tests? If so, an example of that would be helpful; if not, then maybe remove this section. Section: AppExample needs description explaining what is going on in it. |
@dcmaf I've dropped the refs to the external documentation, but was wondering - is your recommendation to drop the hints entirely? They are primarily there to provoke the reader into thinking about an area they have already read about, but I'm thinking of how better to phrase them. Would 'Hint: We covered this in chapter X, page Y' or something similar be more appropriate? |
I think I found the style confusing since it is not consistent with the comment style in other examples in the book, which leaves me question why (e.g., is this a comment style commonly used in QUnit test cases). It is also confusing since the answer seems to be given by the following statement. For instance in: test('Fires a custom event when the state changes.', function() {
expect( 1 );
var spy = this.spy();
var todo = new Todo();
todo.on( 'change', spy );
// How would you update a property on the todo here?
todo.set( { text: 'new text' } );
ok( spy.calledOnce, 'A change event callback was correctly triggered' );
}); By this point, the reader certainly knows how to set a property on a todo, which is what is being done in the next statement. I would think it would be less confusing to simply state what is being done: test('Fires a custom event when the state changes.', function() {
expect( 1 );
var spy = this.spy();
var todo = new Todo();
todo.on( 'change', spy );
// Change the model state
todo.set( { text: 'new text' } );
ok( spy.calledOnce, 'A change event callback was correctly triggered' );
}); Also, looking at that same set of examples for Models, shouldn't the first test have an |
… more readable, adding a few extra comments to examples
…ents to be more readable, adding a few extra comments to examples
Shortest one yet:
Great intro to QUnit, but Backbone is not mentioned even once.
Edit I'll put my Sinon review here too, since chapter 13 is really also part of this chapter (looks like I messed up chapter splitting a little here):
This all looks great!
The text was updated successfully, but these errors were encountered: