Skip to content

Commit

Permalink
with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
enigma committed Nov 15, 2024
1 parent dedfebe commit 963eaff
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ws/test/ext/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,17 @@ describe('web-sockets extension', function() {
this.messages[1].should.contains('"action":"B"')
})

it('maybeClose does not raise when there is no socket', function() {
var div = make('<div hx-ext="ws" ws-connect="ws://localhost:8080"><div id="d1">div1</div></div>')
this.tickMock()
var internalData = div['htmx-internal-data']
should.exist(internalData.webSocket)
delete internalData.webSocket
should.not.exist(internalData.webSocket)
div.parentNode.removeChild(div)
this.tickMock()
})

describe('Send immediately', function() {
function checkCallForWsBeforeSend(spy, wrapper, message, target) {
// Utility function to always check the same for htmx:wsBeforeSend caught by a spy
Expand Down

0 comments on commit 963eaff

Please sign in to comment.