Skip to content

Commit 4ea18ee

Browse files
mcintyre94claude
andcommitted
Add unit tests for ChatStatus computed properties
Tests cover isConnecting, isReconnecting, and isStreaming across all ChatStatus cases, per the PR review suggestion. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5144b25 commit 4ea18ee

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

WispTests/ChatViewModelTests.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,44 @@ struct ChatViewModelTests {
629629
#expect(vm.processedEventUUIDs.isEmpty)
630630
}
631631

632+
// MARK: - ChatStatus computed properties
633+
634+
@Test func chatStatus_isConnecting_onlyForConnecting() {
635+
#expect(ChatStatus.connecting.isConnecting == true)
636+
#expect(ChatStatus.streaming.isConnecting == false)
637+
#expect(ChatStatus.reconnecting.isConnecting == false)
638+
#expect(ChatStatus.idle.isConnecting == false)
639+
#expect(ChatStatus.error("x").isConnecting == false)
640+
}
641+
642+
@Test func chatStatus_isReconnecting_onlyForReconnecting() {
643+
#expect(ChatStatus.reconnecting.isReconnecting == true)
644+
#expect(ChatStatus.connecting.isReconnecting == false)
645+
#expect(ChatStatus.streaming.isReconnecting == false)
646+
#expect(ChatStatus.idle.isReconnecting == false)
647+
#expect(ChatStatus.error("x").isReconnecting == false)
648+
}
649+
650+
@Test func chatStatus_isStreaming_trueForActiveStates() throws {
651+
let ctx = try makeModelContext()
652+
let (vm, _) = makeChatViewModel(modelContext: ctx)
653+
654+
vm.status = .connecting
655+
#expect(vm.isStreaming == true)
656+
657+
vm.status = .streaming
658+
#expect(vm.isStreaming == true)
659+
660+
vm.status = .reconnecting
661+
#expect(vm.isStreaming == true)
662+
663+
vm.status = .idle
664+
#expect(vm.isStreaming == false)
665+
666+
vm.status = .error("oops")
667+
#expect(vm.isStreaming == false)
668+
}
669+
632670
// MARK: - Streaming state (single source of truth)
633671

634672
@Test func currentAssistantMessageId_tracksCurrentMessage() throws {

0 commit comments

Comments
 (0)