mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-28 05:21:18 +00:00

* Fix old npm dependencies * implement web-test-runner tests for headless alongside Mocha browser tests * Increase test and code coverage * update to 100% coverage and impove eslint * Update testing Doco * revert all htmx changes and updates/disable tests needed * fix browser mocha test * Default testing to use playwrite only instead of puppeter * playwright install fix * Imporve test summary reporting * flatten false looks closer to original
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
describe('hx-prompt attribute', function() {
|
|
beforeEach(function() {
|
|
this.server = makeServer()
|
|
clearWorkArea()
|
|
})
|
|
afterEach(function() {
|
|
this.server.restore()
|
|
clearWorkArea()
|
|
})
|
|
|
|
it('hx-prompt should set request header to prompt response', function() {
|
|
this.server.respondWith('GET', '/test', function(xhr) {
|
|
should.equal(xhr.requestHeaders['HX-Prompt'], 'foo')
|
|
xhr.respond(200, {}, 'Clicked!')
|
|
})
|
|
var promptSave = window.prompt
|
|
window.prompt = function() { return 'foo' }
|
|
var btn = make('<button hx-get="/test" hx-prompt="test prompt">Click Me!</a>')
|
|
btn.click()
|
|
this.server.respond()
|
|
window.prompt = promptSave
|
|
btn.innerHTML.should.equal('Clicked!')
|
|
})
|
|
|
|
it('hx-prompt that is cancled returns null and blocks the request', function() {
|
|
this.server.respondWith('GET', '/test', function(xhr) {
|
|
xhr.respond(200, {}, 'Clicked!')
|
|
})
|
|
var promptSave = window.prompt
|
|
window.prompt = function() { return null }
|
|
var btn = make('<button hx-get="/test" hx-prompt="test prompt">Click Me!</a>')
|
|
btn.click()
|
|
this.server.respond()
|
|
window.prompt = promptSave
|
|
btn.innerHTML.should.equal('Click Me!')
|
|
})
|
|
})
|