diff --git a/packages/transport-http/src/subscriptions/mocks/mock-websocket.ts b/packages/transport-http/src/subscriptions/mocks/mock-websocket.ts deleted file mode 100644 index f80842528..000000000 --- a/packages/transport-http/src/subscriptions/mocks/mock-websocket.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { - SubscribeMessageRequest, - SubscribeMessageResponse, - SubscriptionDataMessage, -} from "../models" -import WS from "jest-websocket-mock" - -export class MockWsBackend { - private readonly mockWs: WS - - constructor(endpoint: string) { - this.mockWs = new WS(endpoint) - } - - sendData() { - const data = { - id: "id", - data: {key: "value"}, - } as SubscriptionDataMessage - this.mockWs.send(JSON.stringify(data)) - } - - async respondSubscription(topic: string, args: Record) { - await this.mockWs.connected - - const msg = (await this.mockWs.nextMessage) as string - const data = JSON.parse(msg) as SubscribeMessageRequest - expect(data).toEqual({ - action: "subscribe", - topic, - arguments: args, - }) - - const response: SubscribeMessageResponse = { - id: "id1", - action: "subscribe", - success: true, - topic, - } - this.mockWs.send(JSON.stringify(response)) - } - - get connected() { - return this.mockWs.connected - } - - close() { - this.mockWs.close() - } - - get server() { - return this.mockWs.server - } -}