@@ -1419,13 +1419,12 @@ function sum(a, b) {
14191419
14201420 const result = await strategy . applyDiff ( originalContent , diff )
14211421 expect ( result . success ) . toBe ( false )
1422- if ( ! result . success && result . failParts ) {
1423- const failedPart = result . failParts [ 0 ]
1424- if ( failedPart && "error" in failedPart && failedPart . error ) {
1425- expect ( failedPart . error ) . toContain ( "No sufficiently similar match found" )
1426- } else {
1427- throw new Error ( "Expected failedPart to have an error property" )
1428- }
1422+ if ( ! result . success ) {
1423+ expect ( result . failParts ) . toBeDefined ( )
1424+ expect ( result . failParts ! . length ) . toBeGreaterThan ( 0 )
1425+ const failedPart = result . failParts ! [ 0 ]
1426+ expect ( failedPart ) . toHaveProperty ( "error" )
1427+ expect ( ( failedPart as { error : string } ) . error ) . toContain ( "No sufficiently similar match found" )
14291428 }
14301429 } )
14311430
@@ -1446,19 +1445,18 @@ function sum(a, b) {
14461445
14471446 const result = await strategy . applyDiff ( originalContent , diff )
14481447 expect ( result . success ) . toBe ( false )
1449- if ( ! result . success && result . failParts ) {
1450- const failedPart = result . failParts [ 0 ]
1451- if ( failedPart && "error" in failedPart && failedPart . error ) {
1452- const errorMsg = failedPart . error
1453- expect ( errorMsg ) . toContain ( "Debug Info:" )
1454- expect ( errorMsg ) . toContain ( "Similarity Score:" )
1455- expect ( errorMsg ) . toContain ( "Required Threshold: 95%" )
1456- expect ( errorMsg ) . toContain ( "Levenshtein Distance:" )
1457- expect ( errorMsg ) . toContain ( "Search Length:" )
1458- expect ( errorMsg ) . toContain ( "Best Match Length:" )
1459- } else {
1460- throw new Error ( "Expected failedPart to have an error property" )
1461- }
1448+ if ( ! result . success ) {
1449+ expect ( result . failParts ) . toBeDefined ( )
1450+ expect ( result . failParts ! . length ) . toBeGreaterThan ( 0 )
1451+ const failedPart = result . failParts ! [ 0 ]
1452+ expect ( failedPart ) . toHaveProperty ( "error" )
1453+ const errorMsg = ( failedPart as { error : string } ) . error
1454+ expect ( errorMsg ) . toContain ( "Debug Info:" )
1455+ expect ( errorMsg ) . toContain ( "Similarity Score:" )
1456+ expect ( errorMsg ) . toContain ( "Required Threshold: 95%" )
1457+ expect ( errorMsg ) . toContain ( "Levenshtein Distance:" )
1458+ expect ( errorMsg ) . toContain ( "Search Length:" )
1459+ expect ( errorMsg ) . toContain ( "Best Match Length:" )
14621460 }
14631461 } )
14641462 } )
0 commit comments