52 lines
2.1 KiB
Swift
52 lines
2.1 KiB
Swift
import CoreGraphics
|
|
import HelderCore
|
|
@testable import HelderUI
|
|
import Testing
|
|
|
|
@Suite struct ContextMenuTintTests {
|
|
@Test func addingActionsAreTeal() {
|
|
#expect(ContextMenuOverlay.tint(for: .newFile(inDirectory: "")) == .add)
|
|
#expect(ContextMenuOverlay.tint(for: .newFolder(inDirectory: "src")) == .add)
|
|
#expect(ContextMenuOverlay.tint(for: .stage("a.php")) == .add)
|
|
}
|
|
|
|
@Test func finderUnstageAndCopyFileNameAreAmberSoft() {
|
|
#expect(ContextMenuOverlay.tint(for: .revealInFinder("a.php")) == .modify)
|
|
#expect(ContextMenuOverlay.tint(for: .unstage("a.php")) == .modify)
|
|
#expect(ContextMenuOverlay.tint(for: .copyFileName("a.php")) == .modify)
|
|
}
|
|
|
|
@Test func passOnOpenDiffAndRenameAreGrey() {
|
|
#expect(ContextMenuOverlay.tint(for: .passOnReference("a.php", code: nil)) == .rename)
|
|
#expect(ContextMenuOverlay.tint(for: .passOnFileName("a.php")) == .rename)
|
|
#expect(ContextMenuOverlay.tint(for: .openDiff("a.php")) == .rename)
|
|
#expect(ContextMenuOverlay.tint(for: .rename("a.php", isDirectory: false)) == .rename)
|
|
}
|
|
|
|
@Test func copyReferenceKeepsThePlainIconThatTurnsAmberOnHighlight() {
|
|
#expect(ContextMenuOverlay.tint(for: .copyReference("a.php")) == .plain)
|
|
#expect(MenuIconTint.plain.color == nil)
|
|
}
|
|
|
|
@Test func destructiveActionsAreAmberDeep() {
|
|
#expect(ContextMenuOverlay.tint(for: .discard("a.php")) == .danger)
|
|
#expect(ContextMenuOverlay.tint(for: .delete("a", isDirectory: true)) == .danger)
|
|
}
|
|
}
|
|
|
|
@Suite struct MenuDismissalTests {
|
|
private let menu = CGRect(x: 100, y: 100, width: 320, height: 200)
|
|
|
|
@Test func aClickOutsideTheMenuClosesIt() {
|
|
#expect(MenuDismissal.closes(clickAt: CGPoint(x: 20, y: 20), menuBounds: menu, sameWindow: true))
|
|
}
|
|
|
|
@Test func aClickOnTheMenuLeavesItOpen() {
|
|
#expect(!MenuDismissal.closes(clickAt: CGPoint(x: 150, y: 150), menuBounds: menu, sameWindow: true))
|
|
}
|
|
|
|
@Test func aClickInAnotherWindowLeavesItOpen() {
|
|
#expect(!MenuDismissal.closes(clickAt: CGPoint(x: 20, y: 20), menuBounds: menu, sameWindow: false))
|
|
}
|
|
}
|