import { describe, expect, test } from 'bun:test'; import { wrapHtmlLines, stripLogMarkers, GIT_LINE_MARKER } from '../src/lib/utils/log-lines'; describe('wrapHtmlLines', () => { test('wraps each line in a log-line div', () => { const out = wrapHtmlLines('a\nb'); expect(out).toBe('
a
b
'); }); test('renders an empty line as a non-collapsing space', () => { expect(wrapHtmlLines('')).toBe('
'); }); test('a git-marked line drops the marker and gets the git class + inline svg', () => { const out = wrapHtmlLines(`${GIT_LINE_MARKER}Cloning repository...`); expect(out).toContain('log-line-git'); expect(out).toContain(' { const out = wrapHtmlLines('Container web-1 Started'); expect(out).not.toContain('log-line-git'); expect(out).not.toContain(' { const input = `${GIT_LINE_MARKER}Cloning repository...\n Container web-1 Started\n${GIT_LINE_MARKER}Deploying...`; expect(stripLogMarkers(input)).toBe('Cloning repository...\n Container web-1 Started\nDeploying...'); }); test('stripLogMarkers leaves marker-less text untouched', () => { const input = ' Container web-1 Started\nError response from daemon: boom'; expect(stripLogMarkers(input)).toBe(input); }); test('mixes git and plain lines independently', () => { const out = wrapHtmlLines(`${GIT_LINE_MARKER}Fetching\nContainer web-1 Started`); const parts = out.split('').filter(Boolean); expect(parts[0]).toContain('log-line-git'); expect(parts[1]).toContain('log-line'); expect(parts[1]).not.toContain('log-line-git'); }); });