valid.spec.js (hoppscotch-2.2.1) | : | valid.spec.js (hoppscotch-3.0.0) | ||
---|---|---|---|---|
import { wsValid, httpValid, socketioValid } from "../valid" | import { wsValid, httpValid, socketioValid } from "../valid" | |||
describe("wsValid", () => { | describe("wsValid", () => { | |||
test("returns true for valid URL with IP address", () => { | test("returns true for valid URL with IP address", () => { | |||
expect(wsValid("wss://174.129.224.73/")).toBe(true) | expect(wsValid("wss://174.129.224.73/")).toBe(true) | |||
expect(wsValid("wss://174.129.224.73")).toBe(true) | expect(wsValid("wss://174.129.224.73")).toBe(true) | |||
}) | }) | |||
test("returns true for valid URL with Hostname", () => { | test("returns true for valid URL with Hostname", () => { | |||
expect(wsValid("wss://hoppscotch-websocket.herokuapp.com/")).toBe(true) | expect(wsValid("wss://echo-websocket.hoppscotch.io/")).toBe(true) | |||
expect(wsValid("wss://hoppscotch-websocket.herokuapp.com")).toBe(true) | expect(wsValid("wss://echo-websocket.hoppscotch.io")).toBe(true) | |||
}) | }) | |||
test("returns false for invalid URL with IP address", () => { | test("returns false for invalid URL with IP address", () => { | |||
expect(wsValid("wss://174.129.")).toBe(false) | expect(wsValid("wss://174.129.")).toBe(false) | |||
expect(wsValid("wss://174.129./")).toBe(false) | expect(wsValid("wss://174.129./")).toBe(false) | |||
}) | }) | |||
test("returns false for invalid URL with hostname", () => { | test("returns false for invalid URL with hostname", () => { | |||
expect(wsValid("wss://echo.websocket./")).toBe(false) | expect(wsValid("wss://echo.websocket./")).toBe(false) | |||
expect(wsValid("wss://echo.websocket.")).toBe(false) | expect(wsValid("wss://echo.websocket.")).toBe(false) | |||
}) | }) | |||
test("returns false for non-wss protocol URLs", () => { | test("returns false for non-wss protocol URLs", () => { | |||
expect(wsValid("http://echo.websocket.org/")).toBe(false) | expect(wsValid("http://echo.websocket.org/")).toBe(false) | |||
expect(wsValid("http://echo.websocket.org")).toBe(false) | expect(wsValid("http://echo.websocket.org")).toBe(false) | |||
expect(wsValid("http://174.129.224.73/")).toBe(false) | expect(wsValid("http://174.129.224.73/")).toBe(false) | |||
expect(wsValid("http://174.129.224.73")).toBe(false) | expect(wsValid("http://174.129.224.73")).toBe(false) | |||
}) | }) | |||
test("returns true for wss protocol URLs", () => { | test("returns true for wss protocol URLs", () => { | |||
expect(wsValid("wss://hoppscotch-websocket.herokuapp.com/")).toBe(true) | expect(wsValid("wss://echo-websocket.hoppscotch.io/")).toBe(true) | |||
expect(wsValid("wss://hoppscotch-websocket.herokuapp.com")).toBe(true) | expect(wsValid("wss://echo-websocket.hoppscotch.io")).toBe(true) | |||
expect(wsValid("wss://174.129.224.73/")).toBe(true) | expect(wsValid("wss://174.129.224.73/")).toBe(true) | |||
expect(wsValid("wss://174.129.224.73")).toBe(true) | expect(wsValid("wss://174.129.224.73")).toBe(true) | |||
}) | }) | |||
test("returns true for ws protocol URLs", () => { | test("returns true for ws protocol URLs", () => { | |||
expect(wsValid("ws://echo.websocket.org/")).toBe(true) | expect(wsValid("ws://echo.websocket.org/")).toBe(true) | |||
expect(wsValid("ws://echo.websocket.org")).toBe(true) | expect(wsValid("ws://echo.websocket.org")).toBe(true) | |||
expect(wsValid("ws://174.129.224.73/")).toBe(true) | expect(wsValid("ws://174.129.224.73/")).toBe(true) | |||
expect(wsValid("ws://174.129.224.73")).toBe(true) | expect(wsValid("ws://174.129.224.73")).toBe(true) | |||
}) | }) | |||
skipping to change at line 68 | skipping to change at line 68 | |||
expect(httpValid("http://174.129./")).toBe(false) | expect(httpValid("http://174.129./")).toBe(false) | |||
expect(httpValid("http://174.129.")).toBe(false) | expect(httpValid("http://174.129.")).toBe(false) | |||
}) | }) | |||
test("returns false for invalid URL with hostname", () => { | test("returns false for invalid URL with hostname", () => { | |||
expect(httpValid("http://echo.websocket./")).toBe(false) | expect(httpValid("http://echo.websocket./")).toBe(false) | |||
expect(httpValid("http://echo.websocket.")).toBe(false) | expect(httpValid("http://echo.websocket.")).toBe(false) | |||
}) | }) | |||
test("returns false for non-http(s) protocol URLs", () => { | test("returns false for non-http(s) protocol URLs", () => { | |||
expect(httpValid("wss://hoppscotch-websocket.herokuapp.com/")).toBe(false) | expect(httpValid("wss://echo-websocket.hoppscotch.io/")).toBe(false) | |||
expect(httpValid("wss://hoppscotch-websocket.herokuapp.com")).toBe(false) | expect(httpValid("wss://echo-websocket.hoppscotch.io")).toBe(false) | |||
expect(httpValid("wss://174.129.224.73/")).toBe(false) | expect(httpValid("wss://174.129.224.73/")).toBe(false) | |||
expect(httpValid("wss://174.129.224.73")).toBe(false) | expect(httpValid("wss://174.129.224.73")).toBe(false) | |||
}) | }) | |||
test("returns true for HTTP protocol URLs", () => { | test("returns true for HTTP protocol URLs", () => { | |||
expect(httpValid("http://echo.websocket.org/")).toBe(true) | expect(httpValid("http://echo.websocket.org/")).toBe(true) | |||
expect(httpValid("http://echo.websocket.org")).toBe(true) | expect(httpValid("http://echo.websocket.org")).toBe(true) | |||
expect(httpValid("http://174.129.224.73/")).toBe(true) | expect(httpValid("http://174.129.224.73/")).toBe(true) | |||
expect(httpValid("http://174.129.224.73")).toBe(true) | expect(httpValid("http://174.129.224.73")).toBe(true) | |||
}) | }) | |||
skipping to change at line 132 | skipping to change at line 132 | |||
}) | }) | |||
test("returns true for HTTPS protocol URLs", () => { | test("returns true for HTTPS protocol URLs", () => { | |||
expect(socketioValid("https://echo.websocket.org/")).toBe(true) | expect(socketioValid("https://echo.websocket.org/")).toBe(true) | |||
expect(socketioValid("https://echo.websocket.org")).toBe(true) | expect(socketioValid("https://echo.websocket.org")).toBe(true) | |||
expect(socketioValid("https://174.129.224.73/")).toBe(true) | expect(socketioValid("https://174.129.224.73/")).toBe(true) | |||
expect(socketioValid("https://174.129.224.73")).toBe(true) | expect(socketioValid("https://174.129.224.73")).toBe(true) | |||
}) | }) | |||
test("returns true for wss protocol URLs", () => { | test("returns true for wss protocol URLs", () => { | |||
expect(socketioValid("wss://hoppscotch-websocket.herokuapp.com/")).toBe( | expect(socketioValid("wss://echo-websocket.hoppscotch.io/")).toBe(true) | |||
true | expect(socketioValid("wss://echo-websocket.hoppscotch.io")).toBe(true) | |||
) | ||||
expect(socketioValid("wss://hoppscotch-websocket.herokuapp.com")).toBe(true) | ||||
expect(socketioValid("wss://174.129.224.73/")).toBe(true) | expect(socketioValid("wss://174.129.224.73/")).toBe(true) | |||
expect(socketioValid("wss://174.129.224.73")).toBe(true) | expect(socketioValid("wss://174.129.224.73")).toBe(true) | |||
}) | }) | |||
test("returns true for ws protocol URLs", () => { | test("returns true for ws protocol URLs", () => { | |||
expect(socketioValid("ws://echo.websocket.org/")).toBe(true) | expect(socketioValid("ws://echo.websocket.org/")).toBe(true) | |||
expect(socketioValid("ws://echo.websocket.org")).toBe(true) | expect(socketioValid("ws://echo.websocket.org")).toBe(true) | |||
expect(socketioValid("ws://174.129.224.73/")).toBe(true) | expect(socketioValid("ws://174.129.224.73/")).toBe(true) | |||
expect(socketioValid("ws://174.129.224.73")).toBe(true) | expect(socketioValid("ws://174.129.224.73")).toBe(true) | |||
}) | }) | |||
End of changes. 4 change blocks. | ||||
10 lines changed or deleted | 8 lines changed or added |