Navigation Menu

Skip to content

Commit

Permalink
Add test to validate that blank html is a valid response
Browse files Browse the repository at this point in the history
  • Loading branch information
paltman committed Sep 2, 2013
1 parent 702025a commit 8c10d29
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/tests.js
Expand Up @@ -289,3 +289,32 @@ test("a.click with data-replace-inner response populates div.message", 1, functi
equal($(".message").html(), "My good content", "div.message filled with correct data");
});



module("Blank Handler Tests (jQuery " + jQuery.fn.jquery + ")", {
setup: function () {
var testData = {"html": ""};
this.server = sinon.fakeServer.create();
this.server.respondWith("GET", "/test/message/", [200, {"Content-Type": "application/json"}, JSON.stringify(testData)]);
this.server.respondWith("POST", "/test/message/no-data/", [200, {"Content-Type": "text/html"}, ""]);
this.server.respondWith("GET", "/test/message/400/", [400, {"Content-Type": "application/json"}, JSON.stringify(testData)]);
this.server.respondWith("GET", "/test/message/404/", [404, {"Content-Type": "application/json"}, JSON.stringify(testData)]);
this.server.respondWith("GET", "/test/message/500/", [500, {"Content-Type": "application/json"}, JSON.stringify(testData)]);
this.server.respondWith("GET", "/test/message/503/", [503, {"Content-Type": "application/json"}, JSON.stringify(testData)]);
this.server.respondWith("POST", "/create/message/", [200, {"Content-Type": "application/json"}, JSON.stringify(testData)]);
this.server.respondWith("POST", "/create/message/400/", [400, {"Content-Type": "application/json"}, JSON.stringify(testData)]);
this.server.respondWith("POST", "/create/message/404/", [404, {"Content-Type": "application/json"}, JSON.stringify(testData)]);
this.server.respondWith("POST", "/create/message/500/", [500, {"Content-Type": "application/json"}, JSON.stringify(testData)]);
this.server.respondWith("POST", "/create/message/503/", [503, {"Content-Type": "application/json"}, JSON.stringify(testData)]);
},
teardown: function () {
this.server.restore();
$(".message").html("");
}
});

test("a.click with data-replace-inner response populates div.message", 1, function () {
$("#qunit-fixture a.message-get").trigger("click");
this.server.respond();
equal($(".message").html(), "", "div.message is blank");
});

0 comments on commit 8c10d29

Please sign in to comment.