test(ios): cover voice trigger + camera clamps
This commit is contained in:
24
apps/ios/Tests/CameraControllerClampTests.swift
Normal file
24
apps/ios/Tests/CameraControllerClampTests.swift
Normal file
@@ -0,0 +1,24 @@
|
||||
import Testing
|
||||
@testable import Clawdis
|
||||
|
||||
@Suite struct CameraControllerClampTests {
|
||||
@Test func clampQualityDefaultsAndBounds() {
|
||||
#expect(CameraController.clampQuality(nil) == 0.9)
|
||||
#expect(CameraController.clampQuality(0.0) == 0.05)
|
||||
#expect(CameraController.clampQuality(0.049) == 0.05)
|
||||
#expect(CameraController.clampQuality(0.05) == 0.05)
|
||||
#expect(CameraController.clampQuality(0.5) == 0.5)
|
||||
#expect(CameraController.clampQuality(1.0) == 1.0)
|
||||
#expect(CameraController.clampQuality(1.1) == 1.0)
|
||||
}
|
||||
|
||||
@Test func clampDurationDefaultsAndBounds() {
|
||||
#expect(CameraController.clampDurationMs(nil) == 3000)
|
||||
#expect(CameraController.clampDurationMs(0) == 250)
|
||||
#expect(CameraController.clampDurationMs(249) == 250)
|
||||
#expect(CameraController.clampDurationMs(250) == 250)
|
||||
#expect(CameraController.clampDurationMs(1000) == 1000)
|
||||
#expect(CameraController.clampDurationMs(15000) == 15000)
|
||||
#expect(CameraController.clampDurationMs(15001) == 15000)
|
||||
}
|
||||
}
|
||||
33
apps/ios/Tests/VoiceWakeManagerExtractCommandTests.swift
Normal file
33
apps/ios/Tests/VoiceWakeManagerExtractCommandTests.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
import Testing
|
||||
@testable import Clawdis
|
||||
|
||||
@Suite struct VoiceWakeManagerExtractCommandTests {
|
||||
@Test func extractCommandReturnsNilWhenNoTriggerFound() {
|
||||
#expect(VoiceWakeManager.extractCommand(from: "hello world", triggers: ["clawd"]) == nil)
|
||||
}
|
||||
|
||||
@Test func extractCommandTrimsTokensAndResult() {
|
||||
let cmd = VoiceWakeManager.extractCommand(from: "hey clawd do thing ", triggers: [" clawd "])
|
||||
#expect(cmd == "do thing")
|
||||
}
|
||||
|
||||
@Test func extractCommandPicksLatestTriggerOccurrence() {
|
||||
let transcript = "clawd first\nthen something\nclaude second"
|
||||
let cmd = VoiceWakeManager.extractCommand(from: transcript, triggers: ["clawd", "claude"])
|
||||
#expect(cmd == "second")
|
||||
}
|
||||
|
||||
@Test func extractCommandIsCaseInsensitive() {
|
||||
let cmd = VoiceWakeManager.extractCommand(from: "HELLO CLAWD run it", triggers: ["clawd"])
|
||||
#expect(cmd == "run it")
|
||||
}
|
||||
|
||||
@Test func extractCommandReturnsNilWhenNothingAfterTrigger() {
|
||||
#expect(VoiceWakeManager.extractCommand(from: "hey clawd \n", triggers: ["clawd"]) == nil)
|
||||
}
|
||||
|
||||
@Test func extractCommandIgnoresEmptyTriggers() {
|
||||
let cmd = VoiceWakeManager.extractCommand(from: "hey clawd do thing", triggers: ["", " ", "clawd"])
|
||||
#expect(cmd == "do thing")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user