mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-02 15:25:26 +00:00

The website used to host every past test suite, copied into the www directory. We no longer need that on the website (and it makes the codebase impossible to search) so I removed all the old tests and the new tests are hosted simply at /test. I also replaced the www.js script with a simpler www.sh one (since we no longer need to do anything besides copying, really), which allowed me to remove a node dependency that was only used in that script.
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
describe("method-override extension", function(){
|
|
beforeEach(function() {
|
|
this.server = makeServer();
|
|
clearWorkArea();
|
|
});
|
|
afterEach(function() {
|
|
this.server.restore();
|
|
clearWorkArea();
|
|
});
|
|
|
|
it('issues a DELETE request with proper headers', function()
|
|
{
|
|
this.server.respondWith("DELETE", "/test", function(xhr){
|
|
xhr.requestHeaders['X-HTTP-Method-Override'].should.equal('DELETE');
|
|
xhr.method.should.equal("POST")
|
|
xhr.respond(200, {}, "Deleted!");
|
|
});
|
|
|
|
var btn = make('<button hx-ext="method-override" hx-delete="/test">Click Me!</button>')
|
|
btn.click();
|
|
this.server.respond();
|
|
btn.innerHTML.should.equal("Deleted!");
|
|
});
|
|
|
|
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.method.should.equal("POST")
|
|
xhr.respond(200, {}, "Patched!");
|
|
});
|
|
|
|
var btn = make('<button hx-ext="method-override" hx-patch="/test">Click Me!</button>')
|
|
btn.click();
|
|
this.server.respond();
|
|
btn.innerHTML.should.equal("Patched!");
|
|
});
|
|
|
|
it('issues a PUT request with proper headers', function()
|
|
{
|
|
this.server.respondWith("PUT", "/test", function(xhr){
|
|
xhr.requestHeaders['X-HTTP-Method-Override'].should.equal('PUT');
|
|
xhr.method.should.equal("POST")
|
|
xhr.respond(200, {}, "Putted!");
|
|
});
|
|
|
|
var btn = make('<button hx-ext="method-override" hx-put="/test">Click Me!</button>')
|
|
btn.click();
|
|
this.server.respond();
|
|
btn.innerHTML.should.equal("Putted!");
|
|
});
|
|
|
|
})
|