add tests
This commit is contained in:
parent
ac476cc028
commit
c05dcffc2a
1 changed files with 31 additions and 2 deletions
|
|
@ -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}";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue