htmx/test/attributes/kt-patch.js
2020-05-13 09:12:31 -07:00

24 lines
688 B
JavaScript

describe("kt-patch attribute", function(){
beforeEach(function() {
this.server = makeServer();
clearWorkArea();
});
afterEach(function() {
this.server.restore();
clearWorkArea();
});
it('issues a PATCH request with proper headers', function()
{
this.server.respondWith("PATCH", "/test", function(xhr){
xhr.requestHeaders['X-HTTP-Method-Override'].should.equal('PATCH');
xhr.respond(200, {}, "Patched!");
});
var btn = make('<button kt-patch="/test">Click Me!</button>')
btn.click();
this.server.respond();
btn.innerHTML.should.equal("Patched!");
});
})