describe('hx-history attribute', function() {
var HTMX_HISTORY_CACHE_NAME = 'htmx-history-cache'
beforeEach(function() {
this.server = makeServer()
clearWorkArea()
sessionStorage.removeItem(HTMX_HISTORY_CACHE_NAME)
})
afterEach(function() {
this.server.restore()
clearWorkArea()
sessionStorage.removeItem(HTMX_HISTORY_CACHE_NAME)
})
it('content of hx-history-elt is used during history replacment', function() {
this.server.respondWith('GET', '/test1', '
test1
')
this.server.respondWith('GET', '/test2', 'test2
')
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')
this.server.respondWith('GET', '/test1', 'content outside of hx-history-elt not included
')
// clear cache so it makes a full page request on history restore
sessionStorage.removeItem(HTMX_HISTORY_CACHE_NAME)
htmx._('restoreHistory')('/test1')
this.server.respond()
getWorkArea().textContent.should.equal('test3')
})
})