Skip to content

Commit 4eaf223

Browse files
committed
refactor: move redundant tests
1 parent 0768c5e commit 4eaf223

File tree

1 file changed

+7
-44
lines changed

1 file changed

+7
-44
lines changed

src/services/tree-sitter/__tests__/markdownIntegration.spec.ts

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ describe("Markdown Integration Tests", () => {
2020
vi.clearAllMocks()
2121
})
2222

23-
it("should parse markdown files and extract headers", async () => {
24-
// Mock markdown content
23+
it("should parse markdown files and extract headers for definition listing", async () => {
24+
// This test verifies that the tree-sitter integration correctly
25+
// formats markdown headers for the definition listing feature
2526
const markdownContent =
2627
"# Main Header\n\nThis is some content under the main header.\nIt spans multiple lines to meet the minimum section length.\n\n## Section 1\n\nThis is content for section 1.\nIt also spans multiple lines.\n\n### Subsection 1.1\n\nThis is a subsection with enough lines\nto meet the minimum section length requirement.\n\n## Section 2\n\nFinal section content.\nWith multiple lines.\n"
2728

@@ -34,7 +35,7 @@ describe("Markdown Integration Tests", () => {
3435
// Verify fs.readFile was called with the correct path
3536
expect(fs.readFile).toHaveBeenCalledWith("test.md", "utf8")
3637

37-
// Check the result
38+
// Check the result formatting for definition listing
3839
expect(result).toBeDefined()
3940
expect(result).toContain("# test.md")
4041
expect(result).toContain("1--5 | # Main Header")
@@ -43,8 +44,8 @@ describe("Markdown Integration Tests", () => {
4344
expect(result).toContain("16--20 | ## Section 2")
4445
})
4546

46-
it("should handle markdown files with no headers", async () => {
47-
// Mock markdown content with no headers
47+
it("should return undefined for markdown files with no extractable definitions", async () => {
48+
// This test verifies behavior when no headers meet the minimum requirements
4849
const markdownContent = "This is just some text.\nNo headers here.\nJust plain text."
4950

5051
// Mock fs.readFile to return our markdown content
@@ -56,45 +57,7 @@ describe("Markdown Integration Tests", () => {
5657
// Verify fs.readFile was called with the correct path
5758
expect(fs.readFile).toHaveBeenCalledWith("no-headers.md", "utf8")
5859

59-
// Check the result
60+
// Check the result - should be undefined since no definitions found
6061
expect(result).toBeUndefined()
6162
})
62-
63-
it("should handle markdown files with headers that don't meet minimum section length", async () => {
64-
// Mock markdown content with headers but short sections
65-
const markdownContent = "# Header 1\nShort section\n\n# Header 2\nAnother short section"
66-
67-
// Mock fs.readFile to return our markdown content
68-
;(fs.readFile as Mock).mockImplementation(() => Promise.resolve(markdownContent))
69-
70-
// Call the function with a markdown file path
71-
const result = await parseSourceCodeDefinitionsForFile("short-sections.md")
72-
73-
// Verify fs.readFile was called with the correct path
74-
expect(fs.readFile).toHaveBeenCalledWith("short-sections.md", "utf8")
75-
76-
// Check the result - should be undefined since no sections meet the minimum length
77-
expect(result).toBeUndefined()
78-
})
79-
80-
it("should handle markdown files with mixed header styles", async () => {
81-
// Mock markdown content with mixed header styles
82-
const markdownContent =
83-
"# ATX Header\nThis is content under an ATX header.\nIt spans multiple lines to meet the minimum section length.\n\nSetext Header\n============\nThis is content under a setext header.\nIt also spans multiple lines to meet the minimum section length.\n"
84-
85-
// Mock fs.readFile to return our markdown content
86-
;(fs.readFile as Mock).mockImplementation(() => Promise.resolve(markdownContent))
87-
88-
// Call the function with a markdown file path
89-
const result = await parseSourceCodeDefinitionsForFile("mixed-headers.md")
90-
91-
// Verify fs.readFile was called with the correct path
92-
expect(fs.readFile).toHaveBeenCalledWith("mixed-headers.md", "utf8")
93-
94-
// Check the result
95-
expect(result).toBeDefined()
96-
expect(result).toContain("# mixed-headers.md")
97-
expect(result).toContain("1--4 | # ATX Header")
98-
expect(result).toContain("5--9 | Setext Header")
99-
})
10063
})

0 commit comments

Comments
 (0)