数通智联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
703 B

2 years ago
import { describe, expect, it } from '@jest/globals'
import getSocketHost from './getSocketHost.js'
describe('getSocketHost', () => {
it('should get the host from the specified url', () => {
expect(
getSocketHost('https://foo.bar/a/b/cd?e=fghi&l=k&m=n'),
).toEqual('wss://foo.bar/a/b/cd?e=fghi&l=k&m=n')
expect(
getSocketHost('Https://foo.bar/a/b/cd?e=fghi&l=k&m=n'),
).toEqual('wss://foo.bar/a/b/cd?e=fghi&l=k&m=n')
expect(
getSocketHost('foo.bar/a/b/cd?e=fghi&l=k&m=n'),
).toEqual('wss://foo.bar/a/b/cd?e=fghi&l=k&m=n')
expect(
getSocketHost('http://foo.bar/a/b/cd?e=fghi&l=k&m=n'),
).toEqual('ws://foo.bar/a/b/cd?e=fghi&l=k&m=n')
})
})