UNPKG

e2ed

Version:

E2E testing framework over Playwright

44 lines (43 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WebSocketRoute = void 0; const Route_1 = require("./Route"); const http = 'http:'; const https = 'https:'; /** * Abstract route for WebSocket "requests". */ class WebSocketRoute extends Route_1.Route { /** * Returns `true`, if the request body is in JSON format. */ getIsRequestBodyInJsonFormat() { return true; } /** * Returns `true`, if the response body is in JSON format. */ getIsResponseBodyInJsonFormat() { return true; } /** * Returns the origin of the route. */ getOrigin() { return 'http://localhost'; } /** * Returns the url of the route. */ getUrl() { const url = super.getUrl(); if (url.startsWith(https)) { return `wss:${url.slice(https.length)}`; } if (url.startsWith(http)) { return `ws:${url.slice(http.length)}`; } return url; } } exports.WebSocketRoute = WebSocketRoute;