38 lines
1.1 KiB
Swift
38 lines
1.1 KiB
Swift
import HelderCore
|
|
@testable import HelderUI
|
|
import Testing
|
|
|
|
@Suite struct LauncherListTests {
|
|
private let recents = [
|
|
RecentProject(path: "/code/a", name: "a"),
|
|
RecentProject(path: "/code/b", name: "b"),
|
|
]
|
|
|
|
@Test func theFirstRowOpensTheFolderPicker() {
|
|
let list = LauncherList(recents: recents)
|
|
#expect(list.count == 3)
|
|
#expect(list.selectedChoice == .chooseFolder)
|
|
}
|
|
|
|
@Test func arrowsMoveThroughTheRowsAndStopAtTheEnds() {
|
|
var list = LauncherList(recents: recents)
|
|
list.move(by: -1)
|
|
#expect(list.selection == 0)
|
|
list.move(by: 1)
|
|
#expect(list.selectedChoice == .open(path: "/code/a"))
|
|
list.move(by: 5)
|
|
#expect(list.selectedChoice == .open(path: "/code/b"))
|
|
}
|
|
|
|
@Test func theOpenProjectIsNotOfferedAgain() {
|
|
let list = LauncherList(recents: recents, excluding: "/code/a")
|
|
#expect(list.recents.map(\.path) == ["/code/b"])
|
|
}
|
|
|
|
@Test func hoverSelectionIsClamped() {
|
|
var list = LauncherList(recents: recents)
|
|
list.select(99)
|
|
#expect(list.selection == 2)
|
|
}
|
|
}
|