From c05dcffc2acf70a15200d41610736210d1674e2c Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 2 Dec 2025 18:52:24 +0530 Subject: [PATCH] add tests --- .../findSearchMatch.vitest.ts | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/core/edit/searchAndReplace/findSearchMatch.vitest.ts b/core/edit/searchAndReplace/findSearchMatch.vitest.ts index 54c2f5128..c2489d93e 100644 --- a/core/edit/searchAndReplace/findSearchMatch.vitest.ts +++ b/core/edit/searchAndReplace/findSearchMatch.vitest.ts @@ -109,8 +109,11 @@ describe("findSearchMatch", () => { const searchContent = "hello"; const result = findSearchMatch(fileContent, searchContent); - // Should not match due to case sensitivity, will fall through to other strategies - expect(result).toBeNull(); + expect(result).toEqual({ + startIndex: 0, + endIndex: 5, + strategyName: "caseInsensitiveMatch", + }); }); }); @@ -152,6 +155,32 @@ describe("findSearchMatch", () => { }); }); + describe("Case insensitive match strategy fallback", () => { + it("should match when case differs", () => { + const result = findSearchMatch( + "const myVariable = 42;", + "const MYVARIABLE = 42;", + ); + expect(result).toEqual({ + startIndex: 0, + endIndex: 22, + strategyName: "caseInsensitiveMatch", + }); + }); + + it("should match mixed case in middle of file", () => { + const result = findSearchMatch( + "function HandleClick() {", + "function handleclick() {", + ); + expect(result).toEqual({ + startIndex: 0, + endIndex: 24, + strategyName: "caseInsensitiveMatch", + }); + }); + }); + describe("Whitespace ignored strategy fallback", () => { it("should match content with different whitespace formatting", () => { const fileContent = "function test() {\n return true;\n}";