diff options
Diffstat (limited to 'web/test/fake-socket.ts')
| -rw-r--r-- | web/test/fake-socket.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/web/test/fake-socket.ts b/web/test/fake-socket.ts index 290f9a8..61208e4 100644 --- a/web/test/fake-socket.ts +++ b/web/test/fake-socket.ts @@ -9,13 +9,14 @@ export class FakeSocket implements Transport { onclose: ((ev?: unknown) => void) | null = null; onerror: ((ev?: unknown) => void) | null = null; onmessage: ((ev: { data: unknown }) => void) | null = null; - readyState = 1; // CONNECTING + // Real WebSocket readyState: 0 CONNECTING, 1 OPEN, 2 CLOSING, 3 CLOSED. + readyState = 0; // CONNECTING readonly sent: string[] = []; closed = false; send(data: string): void { - if (this.readyState !== 0) throw new Error('not open'); + if (this.readyState !== 1) throw new Error('not open'); this.sent.push(data); } @@ -29,7 +30,7 @@ export class FakeSocket implements Transport { // test drivers -------------------------------------------------------- open(): void { - this.readyState = 0; + this.readyState = 1; // OPEN this.onopen?.(); } |
