diff options
Diffstat (limited to 'test/attributes/hx-post.js')
-rw-r--r-- | test/attributes/hx-post.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/attributes/hx-post.js b/test/attributes/hx-post.js new file mode 100644 index 00000000..4b548018 --- /dev/null +++ b/test/attributes/hx-post.js @@ -0,0 +1,23 @@ +describe("hx-post attribute", function(){ + beforeEach(function() { + this.server = makeServer(); + clearWorkArea(); + }); + afterEach(function() { + this.server.restore(); + clearWorkArea(); + }); + + it('issues a POST request with proper headers', function() + { + this.server.respondWith("POST", "/test", function(xhr){ + should.equal(xhr.requestHeaders['X-HTTP-Method-Override'], undefined); + xhr.respond(200, {}, "Posted!"); + }); + + var btn = make('<button hx-post="/test">Click Me!</button>') + btn.click(); + this.server.respond(); + btn.innerHTML.should.equal("Posted!"); + }); +}) |