Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions test/attributes/hx-swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,20 +311,21 @@ describe('hx-swap attribute', function() {
done()
})

it('works with transition:true', function(done) {
this.server.respondWith('GET', '/test', 'Clicked!')
var div = make(
"<div hx-get='/test' hx-swap='innerHTML transition:true'></div>"
)
div.click()
this.server.respond()
div.innerText.should.equal('')
setTimeout(function() {
div.innerText.should.equal('Clicked!')
done()
}, 30)
})

if (/chrome/i.test(navigator.userAgent)) {
it('works with transition:true', function(done) {
this.server.respondWith('GET', '/test', 'Clicked!')
var div = make(
"<div hx-get='/test' hx-swap='innerHTML transition:true'></div>"
)
div.click()
this.server.respond()
div.innerText.should.equal('')
setTimeout(function() {
div.innerText.should.equal('Clicked!')
done()
}, 50)
})
}
it('works with a settle delay', function(done) {
this.server.respondWith('GET', '/test', "<div id='d1' class='foo' hx-get='/test' hx-swap='outerHTML settle:10ms'></div>")
var div = make("<div id='d1' hx-get='/test' hx-swap='outerHTML settle:10ms'></div>")
Expand Down
23 changes: 12 additions & 11 deletions test/core/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,17 +494,18 @@ describe('Core htmx API test', function() {
}, 30)
})

it('swap works with a view transition', function(done) {
var div = make("<div hx-get='/test'></div>")
div.innerText.should.equal('')
htmx.swap(div, 'jsswapped', { transition: true })
div.innerText.should.equal('')
setTimeout(function() {
div.innerText.should.equal('jsswapped')
done()
}, 30)
})

if (/chrome/i.test(navigator.userAgent)) {
it('swap works with a view transition', function(done) {
var div = make("<div hx-get='/test'></div>")
div.innerText.should.equal('')
htmx.swap(div, 'jsswapped', { transition: true })
div.innerText.should.equal('')
setTimeout(function() {
div.innerText.should.equal('jsswapped')
done()
}, 50)
})
}
it('swaps content properly (with select)', function() {
var output = make('<output id="output"/>')
htmx.swap('#output', '<div><p id="select-me">Swapped!</p></div>', { swapStyle: 'innerHTML' }, { select: '#select-me' })
Expand Down