import { describe, it, expect } from 'vitest'; import { highlightTs } from './highlight-ts'; describe('highlightTs', () => { it('wraps keywords, strings and comments in the styling spans', () => { const out = highlightTs(`const x = 'hi'; // note`); expect(out).toContain('const'); expect(out).toContain(`'hi'`); expect(out).toContain('// note'); }); it('escapes HTML metacharacters so the [innerHTML] sink is safe', () => { const out = highlightTs(`type T = A & C;`); expect(out).toContain('<B>'); expect(out).toContain('&'); expect(out).not.toContain(''); }); it('treats the whole // tail as one comment (keywords after // are not re-highlighted)', () => { const out = highlightTs(`x(); // return here`); expect(out).toContain('// return here'); expect(out).not.toContain('return'); }); });