getSocketHost.test.ts 696 B

12345678910111213141516171819202122
  1. import { describe, expect, it } from 'vitest'
  2. import getSocketHost from './getSocketHost.ts'
  3. describe('getSocketHost', () => {
  4. it('should get the host from the specified url', () => {
  5. expect(getSocketHost('https://foo.bar/a/b/cd?e=fghi&l=k&m=n')).toEqual(
  6. 'wss://foo.bar/a/b/cd?e=fghi&l=k&m=n',
  7. )
  8. expect(getSocketHost('Https://foo.bar/a/b/cd?e=fghi&l=k&m=n')).toEqual(
  9. 'wss://foo.bar/a/b/cd?e=fghi&l=k&m=n',
  10. )
  11. expect(getSocketHost('foo.bar/a/b/cd?e=fghi&l=k&m=n')).toEqual(
  12. 'wss://foo.bar/a/b/cd?e=fghi&l=k&m=n',
  13. )
  14. expect(getSocketHost('http://foo.bar/a/b/cd?e=fghi&l=k&m=n')).toEqual(
  15. 'ws://foo.bar/a/b/cd?e=fghi&l=k&m=n',
  16. )
  17. })
  18. })