uppy/packages/@uppy/utils/src/getSocketHost.test.ts
Antoine du Hamel 51ecc66e64
@uppy/utils: refactor to TS (#4699)
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
Co-authored-by: Nick Rutten <2504906+nickrttn@users.noreply.github.com>
Co-authored-by: Murderlon <merlijn@soverin.net>
Co-authored-by: Artur Paikin <artur@arturpaikin.com>
2023-11-06 15:01:50 +01:00

22 lines
696 B
TypeScript

import { describe, expect, it } from 'vitest'
import getSocketHost from './getSocketHost.ts'
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',
)
})
})