-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separating test function into its own file
- Loading branch information
Reinier Cruz
committed
Aug 19, 2024
1 parent
69ae50a
commit 8367759
Showing
2 changed files
with
29 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as assert from "assert"; | ||
import { escapeRegExp } from "../../panels/TcpDumpPanel"; | ||
|
||
describe("testEscapeRegExp", function () { | ||
it("should escape special regex characters", function () { | ||
const input = "a.b*c?d+e^f$g|h(i)j{k}l[m]n\\o"; | ||
const expected = "a\\.b\\*c\\?d\\+e\\^f\\$g\\|h\\(i\\)j\\{k\\}l\\[m\\]n\\\\o"; | ||
assert.equal(escapeRegExp(input), expected); | ||
}); | ||
|
||
it("should return the same string if no special characters", function () { | ||
const input = "abcdefg"; | ||
const expected = "abcdefg"; | ||
assert.equal(escapeRegExp(input), expected); | ||
}); | ||
|
||
it("should return an empty string if input is empty", function () { | ||
const input = ""; | ||
const expected = ""; | ||
assert.equal(escapeRegExp(input), expected); | ||
}); | ||
|
||
it("should not double escape already escaped characters", function () { | ||
//const input = "a\\.b\\*c\\?d\\+e\\^f\\$g\\|h\\(i\\)j\\{k\\}l\\[m\\]n\\\\o"; | ||
const expected = "a\\.b\\*c\\?d\\+e\\^f\\$g\\|h\\(i\\)j\\{k\\}l\\[m\\]n\\\\o"; | ||
assert.equal("", expected); | ||
}); | ||
}); |