From 5f5a89512db4a1faacaa0175111e94b5344acc48 Mon Sep 17 00:00:00 2001 From: Bill Ballou Date: Sat, 31 Jan 2026 16:55:06 -0500 Subject: [PATCH] test: add failing tests for withLineNumbers and versionId MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add tests for the new withLineNumbers option in readNote: - Test that content returns numbered lines with arrow prefix (1→) - Test that totalLines count is included in response - Test that versionId is always included in read_note response These tests are expected to fail until the feature is implemented. --- tests/note-tools.test.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/note-tools.test.ts b/tests/note-tools.test.ts index 6279daa..eeac03b 100644 --- a/tests/note-tools.test.ts +++ b/tests/note-tools.test.ts @@ -203,6 +203,46 @@ describe('NoteTools', () => { expect(parsed.content).toBe(content); expect(parsed.wordCount).toBe(5); // Test Note Content here }); + + it('should return numbered lines when withLineNumbers is true', async () => { + const mockFile = createMockTFile('test.md', { + ctime: 1000, + mtime: 2000, + size: 100 + }); + const content = '# Title\n\nParagraph text\nMore text'; + + (PathUtils.resolveFile as jest.Mock).mockReturnValue(mockFile); + mockVault.read = jest.fn().mockResolvedValue(content); + + const result = await noteTools.readNote('test.md', { withLineNumbers: true }); + + expect(result.isError).toBeUndefined(); + const parsed = JSON.parse(result.content[0].text); + expect(parsed.content).toBe('1→# Title\n2→\n3→Paragraph text\n4→More text'); + expect(parsed.totalLines).toBe(4); + expect(parsed.versionId).toBe('2000-100'); + expect(parsed.wordCount).toBe(4); // Title Paragraph text More text + }); + + it('should return versionId even without withLineNumbers', async () => { + const mockFile = createMockTFile('test.md', { + ctime: 1000, + mtime: 2000, + size: 100 + }); + const content = '# Test'; + + (PathUtils.resolveFile as jest.Mock).mockReturnValue(mockFile); + mockVault.read = jest.fn().mockResolvedValue(content); + + const result = await noteTools.readNote('test.md'); + + expect(result.isError).toBeUndefined(); + const parsed = JSON.parse(result.content[0].text); + expect(parsed.content).toBe('# Test'); + expect(parsed.versionId).toBe('2000-100'); + }); }); describe('createNote', () => {