htmx/test/attributes/hx-error-url.js
carson ba6d38e9dd Fix https://github.com/bigskysoftware/htmx/issues/19
clean up uses of getRawAttribute() and add a `data-*` test for all attribute tests.
2020-05-23 04:52:52 -07:00

33 lines
1.1 KiB
JavaScript

describe("hx-error-url attribute", function(){
beforeEach(function() {
this.server = makeServer();
clearWorkArea();
});
afterEach(function() {
this.server.restore();
clearWorkArea();
});
it('Submits a POST with error content on bad request', function()
{
this.server.respondWith("POST", "/error", function(xhr){
should.equal(JSON.parse(xhr.requestBody).detail.xhr.status, 404);
});
var btn = make('<button hx-error-url="/error" hx-get="/bad">Click Me!</button>')
btn.click();
this.server.respond();
this.server.respond();
});
it('Submits a POST with error content on bad request w/ data-* prefix', function()
{
this.server.respondWith("POST", "/error", function(xhr){
should.equal(JSON.parse(xhr.requestBody).detail.xhr.status, 404);
});
var btn = make('<button data-hx-error-url="/error" hx-get="/bad">Click Me!</button>')
btn.click();
this.server.respond();
this.server.respond();
});
})