summaryrefslogtreecommitdiffstatshomepage
path: root/test/attributes/hx-indicator.js
diff options
context:
space:
mode:
authorcarson <carson@leaddyno.com>2020-05-17 05:22:19 -0700
committercarson <carson@leaddyno.com>2020-05-17 05:22:19 -0700
commit3aa8c64754c323f367fae64342f4ac9c20ea5a3d (patch)
tree6de764954d60c019fb87359007919bb56f0fe8f1 /test/attributes/hx-indicator.js
parente1e4f25b0ef21e96eda192e69ab89e207dd7f617 (diff)
downloadhtmx-3aa8c64754c323f367fae64342f4ac9c20ea5a3d.tar.gz
htmx-3aa8c64754c323f367fae64342f4ac9c20ea5a3d.zip
le big re-rename
Diffstat (limited to 'test/attributes/hx-indicator.js')
-rw-r--r--test/attributes/hx-indicator.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/attributes/hx-indicator.js b/test/attributes/hx-indicator.js
new file mode 100644
index 00000000..7b1503bf
--- /dev/null
+++ b/test/attributes/hx-indicator.js
@@ -0,0 +1,36 @@
+describe("hx-indicator attribute", function(){
+ beforeEach(function() {
+ this.server = sinon.fakeServer.create();
+ clearWorkArea();
+ });
+ afterEach(function() {
+ this.server.restore();
+ clearWorkArea();
+ });
+
+ it('Indicator classes are properly put on element with no explicit indicator', function()
+ {
+ this.server.respondWith("GET", "/test", "Clicked!");
+ var btn = make('<button hx-get="/test">Click Me!</button>')
+ btn.click();
+ btn.classList.contains("htmx-request").should.equal(true);
+ this.server.respond();
+ btn.classList.contains("htmx-request").should.equal(false);
+ });
+
+ it('Indicator classes are properly put on element with explicit indicator', function()
+ {
+ this.server.respondWith("GET", "/test", "Clicked!");
+ var btn = make('<button hx-get="/test" hx-indicator="#a1, #a2">Click Me!</button>')
+ var a1 = make('<a id="a1"></a>')
+ var a2 = make('<a id="a2"></a>')
+ btn.click();
+ btn.classList.contains("htmx-request").should.equal(false);
+ a1.classList.contains("htmx-request").should.equal(true);
+ a2.classList.contains("htmx-request").should.equal(true);
+ this.server.respond();
+ btn.classList.contains("htmx-request").should.equal(false);
+ a1.classList.contains("htmx-request").should.equal(false);
+ a2.classList.contains("htmx-request").should.equal(false);
+ });
+})