From a90db7c8dd893515b6f06dc0653a2ea15e4a8dac Mon Sep 17 00:00:00 2001 From: Ariel-Moroshko <45500865+Ariel-Moroshko@users.noreply.github.com> Date: Tue, 29 Oct 2024 06:01:37 +0200 Subject: [PATCH] fix(websocket): Fix typo in WSContextInit type (#3575) --- src/helper/websocket/index.test.ts | 16 ++++++++-------- src/helper/websocket/index.ts | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/helper/websocket/index.test.ts b/src/helper/websocket/index.test.ts index e1efe4fb..0e767788 100644 --- a/src/helper/websocket/index.test.ts +++ b/src/helper/websocket/index.test.ts @@ -1,5 +1,5 @@ import { Context } from '../../context' -import type { WSContestInit } from '.' +import type { WSContextInit } from '.' import { WSContext, createWSMessageEvent, defineWebSocketHelper } from '.' describe('`createWSMessageEvent`', () => { @@ -46,7 +46,7 @@ describe('WSContext', () => { close(code, reason) { resolve([code, reason]) }, - } as WSContestInit) + } as WSContextInit) }) ws.close(0, 'reason') const [code, reason] = await promise @@ -61,7 +61,7 @@ describe('WSContext', () => { send(data, _options) { resolve(data) }, - } as WSContestInit) + } as WSContextInit) }) ws.send('Hello') expect(await promise).toBe('Hello') @@ -69,23 +69,23 @@ describe('WSContext', () => { it('Should readyState works', () => { const ws = new WSContext({ readyState: 0, - } as WSContestInit) + } as WSContextInit) expect(ws.readyState).toBe(0) }) it('Should normalize URL', () => { const stringURLWS = new WSContext({ url: 'http://localhost', - } as WSContestInit) + } as WSContextInit) expect(stringURLWS.url).toBeInstanceOf(URL) const urlURLWS = new WSContext({ url: new URL('http://localhost'), - } as WSContestInit) + } as WSContextInit) expect(urlURLWS.url).toBeInstanceOf(URL) const nullURLWS = new WSContext({ url: undefined, - } as WSContestInit) + } as WSContextInit) expect(nullURLWS.url).toBeNull() }) it('Should normalize message in send()', () => { @@ -95,7 +95,7 @@ describe('WSContext', () => { send(received, _options) { data = received }, - } as WSContestInit) + } as WSContextInit) wsContext.send('string') expect(data).toBe('string') diff --git a/src/helper/websocket/index.ts b/src/helper/websocket/index.ts index c6136dce..e40baa2d 100644 --- a/src/helper/websocket/index.ts +++ b/src/helper/websocket/index.ts @@ -39,7 +39,7 @@ export type WSReadyState = 0 | 1 | 2 | 3 /** * An argument for WSContext class */ -export interface WSContestInit { +export interface WSContextInit { send(data: string | ArrayBuffer, options: SendOptions): void close(code?: number, reason?: string): void @@ -60,8 +60,8 @@ export interface SendOptions { * A context for controlling WebSockets */ export class WSContext { - #init: WSContestInit - constructor(init: WSContestInit) { + #init: WSContextInit + constructor(init: WSContextInit) { this.#init = init this.raw = init.raw this.url = init.url ? new URL(init.url) : null