33 lines
1.4 KiB
Swift
33 lines
1.4 KiB
Swift
import ConjureKit
|
||
import Testing
|
||
|
||
@Test func commandNumbersRequireAnUninterruptedEligibleOneSecondHold() {
|
||
var shortcuts = CommandNumberShortcuts()
|
||
let started = shortcuts.update(commandOnly: true, eligible: true, at: 10)
|
||
let repeated = shortcuts.update(commandOnly: true, eligible: true, at: 10.5)
|
||
let early = shortcuts.reveal(at: 10.999)
|
||
#expect(started && !repeated && !early)
|
||
#expect(shortcuts.index(for: "1") == nil)
|
||
let revealed = shortcuts.reveal(at: 11)
|
||
#expect(revealed)
|
||
#expect(shortcuts.index(for: "1") == 0)
|
||
#expect(shortcuts.index(for: "9") == 8)
|
||
for key in ["0", "10", "k", "", "١"] { #expect(shortcuts.index(for: key) == nil) }
|
||
_ = shortcuts.update(commandOnly: false, eligible: true, at: 11.1)
|
||
#expect(!shortcuts.isVisible)
|
||
let afterRelease = shortcuts.reveal(at: 12)
|
||
#expect(!afterRelease)
|
||
_ = shortcuts.update(commandOnly: true, eligible: true, at: 13)
|
||
_ = shortcuts.update(commandOnly: true, eligible: false, at: 13.5)
|
||
let blocked = shortcuts.reveal(at: 14)
|
||
#expect(!blocked)
|
||
_ = shortcuts.update(commandOnly: true, eligible: true, at: 15)
|
||
let restartedEarly = shortcuts.reveal(at: 15.5)
|
||
let restarted = shortcuts.reveal(at: 16)
|
||
#expect(!restartedEarly && restarted)
|
||
shortcuts.reset()
|
||
#expect(shortcuts.index(for: "2") == nil)
|
||
let afterReset = shortcuts.reveal(at: 20)
|
||
#expect(!afterReset)
|
||
}
|