| 16 | const {createWsSynchronizer} = WsClient; |
| 17 | |
| 18 | class MockWebSocket { |
| 19 | OPEN = 1; |
| 20 | readyState = this.OPEN; |
| 21 | sentPayloads: string[] = []; |
| 22 | readonly #listeners: {[event: string]: ((event: any) => void)[]} = {}; |
| 23 | |
| 24 | addEventListener(event: string, listener: (event: any) => void): void { |
| 25 | (this.#listeners[event] ??= []).push(listener); |
| 26 | } |
| 27 | |
| 28 | removeEventListener(event: string, listener: (event: any) => void): void { |
| 29 | this.#listeners[event] = (this.#listeners[event] ?? []).filter( |
| 30 | (testListener) => testListener != listener, |
| 31 | ); |
| 32 | } |
| 33 | |
| 34 | send(payload: string): void { |
| 35 | this.sentPayloads.push(payload); |
| 36 | } |
| 37 | |
| 38 | receive(payload: string): void { |
| 39 | (this.#listeners.message ?? []).forEach((listener) => |
| 40 | listener({data: payload}), |
| 41 | ); |
| 42 | } |
| 43 | |
| 44 | close(): void { |
| 45 | this.readyState = 3; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | const getFragmentGroup = ( |
| 50 | payloads: string[], |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…