Skip to content

Instantly share code, notes, and snippets.

@caryfitzhugh
Created January 6, 2014 16:06
Show Gist options
  • Save caryfitzhugh/8285017 to your computer and use it in GitHub Desktop.
Save caryfitzhugh/8285017 to your computer and use it in GitHub Desktop.
Suggestion
var response_spy = sinon.spy();
$(document).on('recipes.response_details", response_spy);
$(document).trigger("recipes.request_details", { guid: "123"});
// Now there should be a pending AJAX request to the server.
var req = this.last_xhr_request();
// You can inspect it ot make sure it's going to the right URL, etc. (look at other tests).
req.respond( ...... ); // Not sure of the syntax, but look in other tests to fill in the ajax response.
// Now that the AJAX has completed, we hsould have the response_spy data
equal(response_spy.calledCount, 1);
// And verify some of the fields...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment