describe("hx-history attribute", function() { var HTMX_HISTORY_CACHE_NAME = "htmx-history-cache"; beforeEach(function () { this.server = makeServer(); clearWorkArea(); localStorage.removeItem(HTMX_HISTORY_CACHE_NAME); }); afterEach(function () { this.server.restore(); clearWorkArea(); localStorage.removeItem(HTMX_HISTORY_CACHE_NAME); }); it("history cache should not contain embargoed content", function () { this.server.respondWith("GET", "/test1", '
test1
'); this.server.respondWith("GET", "/test2", '
test2
'); this.server.respondWith("GET", "/test3", '
test3
'); make('
init
'); byId("d1").click(); this.server.respond(); var workArea = getWorkArea(); workArea.textContent.should.equal("test1"); byId("d2").click(); this.server.respond(); workArea.textContent.should.equal("test2"); byId("d3").click(); this.server.respond(); workArea.textContent.should.equal("test3"); // embargoed content should NOT be in the localStorage cache var cache = JSON.parse(localStorage.getItem(HTMX_HISTORY_CACHE_NAME)); cache.length.should.equal(2); // on history navigation, embargoed content is retrieved from server htmx._('restoreHistory')("/test2"); this.server.respond(); getWorkArea().textContent.should.equal("test2"); }); });