summaryrefslogtreecommitdiffstatshomepage
path: root/test/attributes/hx-get.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/attributes/hx-get.js')
-rw-r--r--test/attributes/hx-get.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/attributes/hx-get.js b/test/attributes/hx-get.js
new file mode 100644
index 00000000..3a36da20
--- /dev/null
+++ b/test/attributes/hx-get.js
@@ -0,0 +1,30 @@
+describe("hx-get attribute", function() {
+ beforeEach(function () {
+ this.server = makeServer();
+ clearWorkArea();
+ });
+ afterEach(function () {
+ this.server.restore();
+ clearWorkArea();
+ });
+
+ it('issues a GET request on click and swaps content', function () {
+ this.server.respondWith("GET", "/test", "Clicked!");
+
+ var btn = make('<button hx-get="/test">Click Me!</button>')
+ btn.click();
+ this.server.respond();
+ btn.innerHTML.should.equal("Clicked!");
+ });
+
+ it('GET does not include surrounding data by default', function () {
+ this.server.respondWith("GET", "/test", function (xhr) {
+ xhr.respond(200, {}, "Clicked!");
+ });
+ make('<form><input name="i1" value="value"/><button id="b1" hx-get="/test">Click Me!</inputbutton></form>')
+ var btn = byId("b1");
+ btn.click();
+ this.server.respond();
+ btn.innerHTML.should.equal("Clicked!");
+ });
+}); \ No newline at end of file