23 lines
753 B
TypeScript
23 lines
753 B
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
import { withEditorBasePath } from './public-asset-path'
|
|
|
|
describe('withEditorBasePath', () => {
|
|
test('prefixes root-relative assets for a subpath deployment', () => {
|
|
expect(withEditorBasePath('/icons/select.webp', '/pascal-service')).toBe(
|
|
'/pascal-service/icons/select.webp',
|
|
)
|
|
})
|
|
|
|
test('does not duplicate an existing base path', () => {
|
|
expect(withEditorBasePath('/pascal-service/icons/select.webp', '/pascal-service')).toBe(
|
|
'/pascal-service/icons/select.webp',
|
|
)
|
|
})
|
|
|
|
test('leaves external assets unchanged', () => {
|
|
expect(withEditorBasePath('https://cdn.example/icon.webp', '/pascal-service')).toBe(
|
|
'https://cdn.example/icon.webp',
|
|
)
|
|
})
|
|
})
|