diff options
author | chg20 <469183+chg20@users.noreply.github.com> | 2020-06-28 22:17:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-28 22:17:24 -0700 |
commit | 2fbe230853512b05f0ead8afaf63517280204b86 (patch) | |
tree | d9ff70eef7ddd30470af4716e49542f4376859c6 /test/attributes/hx-push-url.js | |
parent | c7288c16725af38a44c160284ab3c66533e91582 (diff) | |
parent | 8ee306d178a42dcaf8f9b2b575f8eed2b73dd9fe (diff) | |
download | htmx-2fbe230853512b05f0ead8afaf63517280204b86.tar.gz htmx-2fbe230853512b05f0ead8afaf63517280204b86.zip |
Merge pull request #122 from bencroker/patch-8
Allowed `hx-push-url` to accept a string
Diffstat (limited to 'test/attributes/hx-push-url.js')
-rw-r--r-- | test/attributes/hx-push-url.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/attributes/hx-push-url.js b/test/attributes/hx-push-url.js index 81983f80..50b5825d 100644 --- a/test/attributes/hx-push-url.js +++ b/test/attributes/hx-push-url.js @@ -13,7 +13,7 @@ describe("hx-push-url attribute", function() { localStorage.removeItem(HTMX_HISTORY_CACHE_NAME); }); - it("navigation should push an element into the cache ", function () { + it("navigation should push an element into the cache when true", function () { this.server.respondWith("GET", "/test", "second"); getWorkArea().innerHTML.should.be.equal(""); var div = make('<div hx-push-url="true" hx-get="/test">first</div>'); @@ -22,6 +22,19 @@ describe("hx-push-url attribute", function() { getWorkArea().textContent.should.equal("second") var cache = JSON.parse(localStorage.getItem(HTMX_HISTORY_CACHE_NAME)); cache.length.should.equal(1); + cache[0].url.should.equal("/test"); + }); + + it("navigation should push an element into the cache when string", function () { + this.server.respondWith("GET", "/test", "second"); + getWorkArea().innerHTML.should.be.equal(""); + var div = make('<div hx-push-url="/abc123" hx-get="/test">first</div>'); + div.click(); + this.server.respond(); + getWorkArea().textContent.should.equal("second") + var cache = JSON.parse(localStorage.getItem(HTMX_HISTORY_CACHE_NAME)); + cache.length.should.equal(1); + cache[0].url.should.equal("/abc123"); }); it("restore should return old value", function () { |