Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions __tests__/lib/mdx.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { mdast, mdx } from '../../index';

describe('mdx serialization', () => {
it('should not add indentation to JSX comment content when serializing', () => {
const md = `
{/*

## Hey-o

*/}
`;

const tree = mdast(md, { missingComponents: 'ignore' });
const serialized = mdx(tree);

// Extract the comment content line
const commentMatch = serialized.match(/\{\/\*([\s\S]*?)\*\/\}/);
const commentContent = commentMatch?.[1];
const contentLine = commentContent?.split('\n').find(line => line.includes('## Hey-o'));

// Check that the line does NOT have leading spaces (indentation)
expect(contentLine).not.toMatch(/^\s+/);
});
});

Loading