diff options
Diffstat (limited to 'packages/core/src/tools/write-file.test.ts')
| -rw-r--r-- | packages/core/src/tools/write-file.test.ts | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/packages/core/src/tools/write-file.test.ts b/packages/core/src/tools/write-file.test.ts index 4646f30a..3f9825c6 100644 --- a/packages/core/src/tools/write-file.test.ts +++ b/packages/core/src/tools/write-file.test.ts @@ -567,5 +567,49 @@ describe('WriteFileTool', () => { expect(fs.existsSync(filePath)).toBe(true); expect(fs.readFileSync(filePath, 'utf8')).toBe(content); }); + + it('should include modification message when proposed content is modified', async () => { + const filePath = path.join(rootDir, 'new_file_modified.txt'); + const content = 'New file content modified by user'; + mockEnsureCorrectFileContent.mockResolvedValue(content); + + const params = { + file_path: filePath, + content, + modified_by_user: true, + }; + const result = await tool.execute(params, abortSignal); + + expect(result.llmContent).toMatch(/User modified the `content`/); + }); + + it('should not include modification message when proposed content is not modified', async () => { + const filePath = path.join(rootDir, 'new_file_unmodified.txt'); + const content = 'New file content not modified'; + mockEnsureCorrectFileContent.mockResolvedValue(content); + + const params = { + file_path: filePath, + content, + modified_by_user: false, + }; + const result = await tool.execute(params, abortSignal); + + expect(result.llmContent).not.toMatch(/User modified the `content`/); + }); + + it('should not include modification message when modified_by_user is not provided', async () => { + const filePath = path.join(rootDir, 'new_file_unmodified.txt'); + const content = 'New file content not modified'; + mockEnsureCorrectFileContent.mockResolvedValue(content); + + const params = { + file_path: filePath, + content, + }; + const result = await tool.execute(params, abortSignal); + + expect(result.llmContent).not.toMatch(/User modified the `content`/); + }); }); }); |
