overleaf-cep/services/web/test/frontend/shared/utils/url-helper.test.js
Alf Eaton a8a61db23e Convert shared utils modules to TypeScript (#22665)
GitOrigin-RevId: de40a0aaba35336ec59499a047356b0b9d161b38
2025-01-14 09:04:50 +00:00

45 lines
1.5 KiB
JavaScript

import { expect } from 'chai'
import { cleanURL } from '@/shared/utils/url-helper'
describe('url-helper', function () {
describe('cleanURL', function () {
describe('without mode', function () {
it('removes trailing slash', function () {
const url = new URL('https://www.ovelreaf.com/project/1abc/')
expect(cleanURL(url).href).to.equal(
'https://www.ovelreaf.com/project/1abc'
)
})
it('clears the mode from the detached URL', function () {
const url = new URL('https://www.ovelreaf.com/project/2abc/detached')
expect(cleanURL(url).href).to.equal(
'https://www.ovelreaf.com/project/2abc'
)
})
it('clears the mode from the detacher URL', function () {
const url = new URL('https://www.ovelreaf.com/project/2abc/detacher/')
expect(cleanURL(url).href).to.equal(
'https://www.ovelreaf.com/project/2abc'
)
})
})
describe('with mode', function () {
it('handles with trailing slash', function () {
const url = new URL('https://www.ovelreaf.com/project/3abc/')
expect(cleanURL(url, 'detacher').href).to.equal(
'https://www.ovelreaf.com/project/3abc/detacher'
)
})
it('handles without trailing slash', function () {
const url = new URL('https://www.ovelreaf.com/project/4abc')
expect(cleanURL(url, 'detached').href).to.equal(
'https://www.ovelreaf.com/project/4abc/detached'
)
})
})
})
})