| 49 | } |
| 50 | |
| 51 | function createConnectingWebSocketClass() { |
| 52 | // Starts in CONNECTING state; tests flip readyState and fire onopen manually. |
| 53 | return class ConnectingWebSocket { |
| 54 | static CONNECTING = 0 |
| 55 | static OPEN = 1 |
| 56 | static CLOSED = 3 |
| 57 | url: string |
| 58 | readyState = 0 // CONNECTING |
| 59 | onopen: any = null |
| 60 | onmessage: any = null |
| 61 | onclose: any = null |
| 62 | onerror: any = null |
| 63 | send = vi.fn() |
| 64 | close = vi.fn() |
| 65 | constructor(url: string) { |
| 66 | this.url = url |
| 67 | mockWebSocketInstances.push(this) |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | function createThrowingWebSocketClass() { |
| 73 | return class ThrowingWebSocket { |