@@ -191,34 +191,6 @@ describe("Empty search content", () => {
191191 } ) ;
192192} ) ;
193193
194- describe ( "No matches" , ( ) => {
195- it ( "should return null when search content is not found" , ( ) => {
196- const fileContent = `function hello() {
197- console.log("world");
198- }` ;
199- const searchContent = `function goodbye() {
200- console.log("world");
201- }` ;
202-
203- const result = findSearchMatch ( fileContent , searchContent ) ;
204-
205- expect ( result ?. strategyName ) . toEqual ( "jaroWinklerFuzzyMatch" ) ;
206- } ) ;
207-
208- it ( "should return only fuzzy result when trimmed search content is not found" , ( ) => {
209- const fileContent = `function hello() {
210- console.log("world");
211- }` ;
212- const searchContent = `\n\nfunction goodbye() {
213- console.log("world");
214- }\n\n` ;
215-
216- const result = findSearchMatch ( fileContent , searchContent ) ;
217-
218- expect ( result ?. strategyName ) . toEqual ( "jaroWinklerFuzzyMatch" ) ;
219- } ) ;
220- } ) ;
221-
222194describe ( "Edge cases" , ( ) => {
223195 it ( "should handle empty file with non-empty search" , ( ) => {
224196 const fileContent = "" ;
@@ -612,157 +584,4 @@ function test() {
612584 strategyName : "exactMatch" ,
613585 } ) ;
614586 } ) ;
615-
616- describe ( "Jaro-Winkler fuzzy matching" , ( ) => {
617- describe ( "Basic fuzzy matching" , ( ) => {
618- it ( "should find fuzzy match for similar strings" , ( ) => {
619- const fileContent = `function calculateSum(a, b) {
620- return a + b;
621- }` ;
622- const searchContent = `function calculateSum(x, y) {
623- return x + y;
624- }` ;
625-
626- const result = findSearchMatch ( fileContent , searchContent ) ;
627-
628- expect ( result ) . not . toBeNull ( ) ;
629- } ) ;
630-
631- it ( "should find fuzzy match with minor typos" , ( ) => {
632- const fileContent = `const message = "Hello World";` ;
633- const searchContent = `const mesage = "Hello World";` ; // Missing 's' in 'message'
634-
635- const result = findSearchMatch ( fileContent , searchContent ) ;
636-
637- expect ( result ) . not . toBeNull ( ) ;
638- expect ( result ?. startIndex ) . toBe ( 0 ) ;
639- } ) ;
640-
641- it ( "should find fuzzy match with different variable names" , ( ) => {
642- const fileContent = `let userAge = 25;
643- let userName = "John";` ;
644- const searchContent = `let age = 25;
645- let name = "John";` ;
646-
647- const result = findSearchMatch ( fileContent , searchContent ) ;
648-
649- expect ( result ) . not . toBeNull ( ) ;
650- } ) ;
651-
652- it ( "should find fuzzy match for similar function signature" , ( ) => {
653- const fileContent = `function processUserData(userData) {
654- validateInput(userData);
655- return formatOutput(userData);
656- }` ;
657- const searchContent = `function processData(data) {
658- validateInput(data);
659- return formatOutput(data);
660- }` ;
661-
662- const result = findSearchMatch ( fileContent , searchContent ) ;
663-
664- expect ( result ) . not . toBeNull ( ) ;
665- } ) ;
666- } ) ;
667-
668- describe ( "Multi-line fuzzy matching" , ( ) => {
669- it ( "should find fuzzy match for multi-line blocks" , ( ) => {
670- const fileContent = `class Calculator {
671- constructor() {
672- this.result = 0;
673- }
674-
675- add(value) {
676- this.result += value;
677- return this;
678- }
679- }` ;
680- const searchContent = `class Calculator {
681- constructor() {
682- this.value = 0;
683- }
684-
685- add(num) {
686- this.value += num;
687- return this;
688- }
689- }` ;
690-
691- const result = findSearchMatch ( fileContent , searchContent ) ;
692-
693- expect ( result ) . not . toBeNull ( ) ;
694- } ) ;
695-
696- it ( "should find fuzzy match for partial blocks" , ( ) => {
697- const fileContent = `function processData(input) {
698- const validated = validateInput(input);
699- const processed = transformData(validated);
700- const result = formatOutput(processed);
701- return result;
702- }` ;
703- const searchContent = `const validated = validateInput(input);
704- const processed = transformData(validated);` ;
705-
706- const result = findSearchMatch ( fileContent , searchContent ) ;
707-
708- expect ( result ) . not . toBeNull ( ) ;
709- } ) ;
710- } ) ;
711-
712- describe ( "Edge cases with fuzzy matching" , ( ) => {
713- it ( "should handle empty search content with fuzzy matching enabled" , ( ) => {
714- const fileContent = `function test() {}` ;
715- const searchContent = "" ;
716-
717- const result = findSearchMatch ( fileContent , searchContent ) ;
718-
719- expect ( result ) . toEqual ( {
720- startIndex : 0 ,
721- endIndex : 0 ,
722- strategyName : "emptySearch" ,
723- } ) ;
724- } ) ;
725-
726- it ( "should handle empty file content with fuzzy matching enabled" , ( ) => {
727- const fileContent = "" ;
728- const searchContent = "function test() {}" ;
729-
730- const result = findSearchMatch ( fileContent , searchContent ) ;
731-
732- expect ( result ) . toBeNull ( ) ;
733- } ) ;
734-
735- it ( "should prefer exact match over fuzzy match" , ( ) => {
736- const fileContent = `function test() { return true; }
737- function test() { return false; }` ;
738- const searchContent = `function test() { return true; }` ;
739-
740- const result = findSearchMatch ( fileContent , searchContent ) ;
741-
742- expect ( result ) . not . toBeNull ( ) ;
743- expect ( result ?. startIndex ) . toBe ( 0 ) ;
744- } ) ;
745-
746- it ( "should handle very short strings" , ( ) => {
747- const fileContent = `a b c` ;
748- const searchContent = `a c` ;
749-
750- const result = findSearchMatch ( fileContent , searchContent ) ;
751-
752- // Should not match due to low similarity
753- expect ( result ) . toBeNull ( ) ;
754- } ) ;
755-
756- it ( "should handle special characters in fuzzy matching" , ( ) => {
757- const fileContent = `const regex = /[a-zA-Z]+/g;
758- const symbols = !@#$%^&*();` ;
759- const searchContent = `const regex = /[a-zA-Z0-9]+/g;
760- const symbols = !@#$%^&*();` ;
761-
762- const result = findSearchMatch ( fileContent , searchContent ) ;
763-
764- expect ( result ) . not . toBeNull ( ) ;
765- } ) ;
766- } ) ;
767- } ) ;
768587} ) ;
0 commit comments