Spaces:
Paused
Paused
File size: 1,098 Bytes
9ada4bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import { describe, it, expect } from 'vitest'
import { getCleanUrl } from './getCleanUrl'
describe('getCleanUrl', () => {
describe('given a URL without query parameters', () => {
it('should return url href as-is', () => {
const url = new URL('https://github.com')
expect(getCleanUrl(url)).toEqual('https://github.com/')
})
})
describe('given a URL with query parameters', () => {
it('should return url without parameters', () => {
const url = new URL('https://github.com/mswjs/?userId=abc-123')
expect(getCleanUrl(url)).toEqual('https://github.com/mswjs/')
})
})
describe('given a URL with a hash', () => {
it('should return a url without hash', () => {
const url = new URL('https://github.com/mswjs/#hello-world')
expect(getCleanUrl(url)).toEqual('https://github.com/mswjs/')
})
})
describe('given an absolute URL ', () => {
it('should return a clean relative URL', () => {
const url = new URL('/login?query=value', 'https://github.com')
expect(getCleanUrl(url, false)).toEqual('/login')
})
})
})
|