Skip to content

Instantly share code, notes, and snippets.

@cjohansen
Created March 18, 2011 21:19
Show Gist options
  • Save cjohansen/876874 to your computer and use it in GitHub Desktop.
Save cjohansen/876874 to your computer and use it in GitHub Desktop.
TestCase("AjaxTest", sinon.testCase({
testJSONResponse: function () {
this.server.respondWith(
"POST", /post.*/,
[200, { "Content-Type": "application/json"},
'{ "Exception":"", "Success":"true", "ValidationResult":"" }']);
$.post("/post", "data=here", function (data) {
jstestdriver.console.log(typeof data, data);
}, "json");
this.server.respond();
}
}));
// .
// Total 1 tests (Passed: 1; Fails: 0; Errors: 0) (2.00 ms)
// Firefox 3.6.15 Linux: Run 1 tests (Passed: 1; Fails: 0; Errors 0) (2.00 ms)
// AjaxTest.testJSONResponse passed (2.00 ms)
// [LOG] object {"Exception":"","Success":"true","ValidationResult":""}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment