From e00ec0cc3f350f01c5ea2ff8bd12ad15e025302b Mon Sep 17 00:00:00 2001 From: Daniel Riccio Date: Tue, 14 Jan 2025 17:57:55 -0500 Subject: [PATCH] test: add unit tests for NewUnifiedDiffStrategy constructor and confidence threshold behavior - Introduced tests for the NewUnifiedDiffStrategy constructor to verify default and custom confidence thresholds. - Ensured that the minimum confidence threshold is enforced, preventing values below 0.8. - Enhanced test coverage for the strategy's initialization logic, improving overall reliability and maintainability. --- .../strategies/__tests__/new-unified.test.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/core/diff/strategies/__tests__/new-unified.test.ts b/src/core/diff/strategies/__tests__/new-unified.test.ts index 387988b..e1d568e 100644 --- a/src/core/diff/strategies/__tests__/new-unified.test.ts +++ b/src/core/diff/strategies/__tests__/new-unified.test.ts @@ -5,7 +5,24 @@ describe('main', () => { let strategy: NewUnifiedDiffStrategy beforeEach(() => { - strategy = new NewUnifiedDiffStrategy() + strategy = new NewUnifiedDiffStrategy(0.97) + }) + + describe('constructor', () => { + it('should use default confidence threshold when not provided', () => { + const defaultStrategy = new NewUnifiedDiffStrategy() + expect(defaultStrategy['confidenceThreshold']).toBe(0.9) + }) + + it('should use provided confidence threshold', () => { + const customStrategy = new NewUnifiedDiffStrategy(0.85) + expect(customStrategy['confidenceThreshold']).toBe(0.85) + }) + + it('should enforce minimum confidence threshold', () => { + const lowStrategy = new NewUnifiedDiffStrategy(0.7) // Below minimum of 0.8 + expect(lowStrategy['confidenceThreshold']).toBe(0.8) + }) }) describe('getToolDescription', () => {