Skip to content

Commit c488e07

Browse files
committed
test: add unit test to cover issue #75 case
1 parent 8ff786e commit c488e07

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/lib/tags.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ Some text\n`;
1212
expect(result).toContain('<!-- index-start -->');
1313
expect(result).toContain('<!-- index-end -->');
1414
});
15+
16+
it('should not pull content from below H2 headings', () => {
17+
const mockContent = `# Test
18+
19+
## A
20+
21+
Some H2 text that should not be pulled to heading
22+
23+
### B - not pulled
24+
25+
Some H3 text not pulled to heading
26+
27+
## C
28+
29+
### D - H3 should not be pulled because parent H2 has no text`;
30+
31+
const result = findFirstParagraph(mockContent);
32+
expect(result).toContain('## A\n\nSome H2 text that should not be pulled to heading');
33+
expect(result).toContain('## C\n\n### D - H3 should not be pulled because parent H2 has no text');
34+
expect(result).not.toContain('## ASome H2 text');
35+
expect(result).not.toContain('## C### D');
36+
});
1537
});
1638

1739
describe('replacetag (Function)', () => {

0 commit comments

Comments
 (0)