33 lines
1.2 KiB
Swift
33 lines
1.2 KiB
Swift
import Testing
|
|
@testable import SstCore
|
|
|
|
struct HotkeyBindingTests {
|
|
@Test func allowedBindingsMatchTheSpec() {
|
|
#expect(HotkeyBinding.allowed.map(\.id) == ["fn", "rightOption", "rightCommand", "rightControl", "leftControl"])
|
|
#expect(HotkeyBinding.allowed.map(\.keyCode) == [63, 61, 54, 62, 59])
|
|
}
|
|
|
|
@Test func idsAndKeyCodesAreUnique() {
|
|
#expect(Set(HotkeyBinding.allowed.map(\.id)).count == HotkeyBinding.allowed.count)
|
|
#expect(Set(HotkeyBinding.allowed.map(\.keyCode)).count == HotkeyBinding.allowed.count)
|
|
}
|
|
|
|
@Test func lookupByKeyCodeAndId() {
|
|
#expect(HotkeyBinding.binding(keyCode: 61) == .rightOption)
|
|
#expect(HotkeyBinding.binding(id: "leftControl") == .leftControl)
|
|
}
|
|
|
|
@Test func unsupportedKeysAreRejected() {
|
|
#expect(HotkeyBinding.binding(keyCode: 56) == nil) // left shift
|
|
#expect(HotkeyBinding.binding(keyCode: 57) == nil) // caps lock
|
|
#expect(HotkeyBinding.binding(id: "nope") == nil)
|
|
}
|
|
|
|
@Test func everyBindingHasAFlagAndName() {
|
|
for binding in HotkeyBinding.allowed {
|
|
#expect(binding.flagRawValue != 0)
|
|
#expect(!binding.displayName.isEmpty)
|
|
}
|
|
}
|
|
}
|