import { describe, expect, it } from 'vitest'; import { stripCodeFenceFromArtifact } from './Markdown'; describe('stripCodeFenceFromArtifact', () => { it('should remove code fences around artifact element', () => { const input = "```xml\n
\n```"; const expected = "\n
\n"; expect(stripCodeFenceFromArtifact(input)).toBe(expected); }); it('should handle code fence with language specification', () => { const input = "```typescript\n
\n```"; const expected = "\n
\n"; expect(stripCodeFenceFromArtifact(input)).toBe(expected); }); it('should not modify content without artifacts', () => { const input = '```\nregular code block\n```'; expect(stripCodeFenceFromArtifact(input)).toBe(input); }); it('should handle empty input', () => { expect(stripCodeFenceFromArtifact('')).toBe(''); }); it('should handle artifact without code fences', () => { const input = "
"; expect(stripCodeFenceFromArtifact(input)).toBe(input); }); it('should handle multiple artifacts but only remove fences around them', () => { const input = [ 'Some text', '```typescript', "
", '```', '```', 'regular code', '```', ].join('\n'); const expected = ['Some text', '', "
", '', '```', 'regular code', '```'].join( '\n', ); expect(stripCodeFenceFromArtifact(input)).toBe(expected); }); });