restores Helder in all its glory
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import HelderCore
|
||||
import Testing
|
||||
|
||||
@Suite struct FuzzyTests {
|
||||
@Test func matchesSubsequencesCaseInsensitively() {
|
||||
#expect(Fuzzy.match("uc", in: "UserController.php") == [0, 4])
|
||||
#expect(Fuzzy.match("xyz", in: "UserController.php") == nil)
|
||||
}
|
||||
|
||||
@Test func ranksBasenameMatchesFirst() {
|
||||
let paths = ["src/user/list.php", "app/UserList.php", ".env"]
|
||||
let ranked = Fuzzy.rankFileNames(query: "userl", paths: paths, showHidden: false)
|
||||
#expect(ranked.map(\.path) == ["app/UserList.php", "src/user/list.php"])
|
||||
#expect(ranked[0].rank == 0 && ranked[1].rank == 1)
|
||||
}
|
||||
}
|
||||
|
||||
@Suite struct FuzzyPortedTests {
|
||||
@Test("an empty query matches nothing in the ranked list")
|
||||
func emptyQuery() {
|
||||
#expect(Fuzzy.rankFileNames(query: " ", paths: ["a.ts"], showHidden: true).isEmpty)
|
||||
#expect(Fuzzy.match("", in: "abc") == [])
|
||||
}
|
||||
|
||||
@Test("hidden paths are left out unless asked for")
|
||||
func hiddenPaths() {
|
||||
#expect(Fuzzy.rankFileNames(query: "env", paths: [".env"], showHidden: false).isEmpty)
|
||||
#expect(Fuzzy.rankFileNames(query: "env", paths: [".env"], showHidden: true).map(\.path) == [".env"])
|
||||
}
|
||||
|
||||
@Test("in-file hits are case-insensitive with UTF-16 offsets")
|
||||
func inFileHits() {
|
||||
let hits = InFileSearch.hits(query: "Bal", in: "😀 balance\nnone\nBALANCE")
|
||||
#expect(hits == [ContentHit(line: 1, text: "😀 balance", matchOffset: 3), ContentHit(line: 3, text: "BALANCE", matchOffset: 0)])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user