import { cleanMarkdownNbsp } from './cleanMarkdownNbsp'; describe('cleanMarkdownNbsp', () => { it('should return unchanged text if no is present', () => { const input = '# Heading\n\nSome paragraph\n\n- [ ] Todo item'; expect(cleanMarkdownNbsp(input)).toBe(input); }); it('should clean standalone lines between paragraphs and items', () => { const input = [ 'jjjj', '', ' ', '', 'jjj', '', '', '', ' ', '', '- [x] 2026/11/01 16:24', ].join('\n'); const expected = [ 'jjjj', '', 'jjj', '', '', '', '- [x] 2026/11/01 16:24', ].join('\n'); expect(cleanMarkdownNbsp(input)).toBe(expected); }); it('should clean multiple contiguous or spaced entities and variants ( , )', () => { const input = [ 'Section 1', ' ', 'Section 2', ' ', 'Section 3', ' ', 'Section 4', ' ', 'Section 5', ].join('\n'); const expected = [ 'Section 1', '', 'Section 2', '', 'Section 3', '', 'Section 4', '', 'Section 5', ].join('\n'); expect(cleanMarkdownNbsp(input)).toBe(expected); }); it('should preserve inline inside text and table cells', () => { const text = 'Hello world with inline nonbreaking space.'; expect(cleanMarkdownNbsp(text)).toBe(text); const table = '| Header 1 | Header 2 |\n| --- | --- |\n| | Value |'; expect(cleanMarkdownNbsp(table)).toBe(table); }); it('should preserve inline backtick code spans like ` `', () => { const text = 'Use ` ` for non-breaking space in HTML.'; expect(cleanMarkdownNbsp(text)).toBe(text); }); it('should preserve inside fenced code blocks', () => { const codeBlock = [ '```html', ' ', '