Skip to content

Commit

Permalink
Add testcase for when heading is within frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
dvcrn committed Dec 20, 2024
1 parent fb8710b commit 9badf34
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,26 @@ describe('FilenameHeadingSyncPlugin', () => {
expect(result?.style).toBe('Prefix');
expect(result?.lineNumber).toBe(1);
});

it('should ignore heading inside frontmatter', () => {
const fileLines = [
'---',
'# Not a heading',
'title: Test',
'---',
'# Actual Heading',
'Some content',
];

const result = plugin.findHeading(
fileLines,
plugin.findNoteStart(fileLines),
);

expect(result).not.toBeNull();
expect(result?.text).toBe('Actual Heading');
expect(result?.style).toBe('Prefix');
expect(result?.lineNumber).toBe(4);
});
});
});

0 comments on commit 9badf34

Please sign in to comment.