mock-socket
mock-socket copied to clipboard
setTimeout on websocket close handler
I'm sure this reasoning could apply to other areas in the code base... but it seems if you want websocket to mimic its real life counterpart, all the functionaliy inside websocket.close() should happen behind a setTimeout call.
Currently I'm writing a test verify that the readyState on the websocket is set to CLOSING immediately after I invoke websocket.close. Because websocket.close occurs synchronously it's impossible to test for this. Thoughts?