/** * HTML preview vocabulary tests: the srcdoc delivery path needs the previewed * document's relative references to resolve back into its own * `/sidebar/html/…` route (a srcdoc document has no URL of its own — the * browser would otherwise resolve `./style.css` against the GUI page). * * Pure module, plain node environment. */ import { describe, expect, it } from 'vitest' import { previewBaseOf, withPreviewBase } from '../src/client/html-preview.ts' const URL_ = '/sidebar/html/s1/p/a/index.html' describe('previewBaseOf', () => { it('keeps everything up to the last slash', () => { expect(previewBaseOf(URL_)).toBe('/sidebar/html/s1/p/a/') }) it('keeps the UNC double slash intact (the route encodes it that way)', () => { expect(previewBaseOf('/sidebar/html/s1//server/share/a.html')).toBe('/sidebar/html/s1//server/share/') }) it('returns the input unchanged when it has no slash', () => { expect(previewBaseOf('s1')).toBe('s1') }) }) describe('withPreviewBase', () => { it('injects the base as the first child of
, ahead of the document’s own elements', () => { const out = withPreviewBase('