- Add VoiceOver labels, hints, and element grouping across all 60+ views - Add Reduce Motion support (Theme.Animation.prefersReducedMotion) to all animations - Replace fixed font sizes with semantic Dynamic Type styles - Hide decorative elements from VoiceOver with .accessibilityHidden(true) - Add .minimumHitTarget() modifier ensuring 44pt touch targets - Add AccessibilityAnnouncer utility for VoiceOver announcements - Improve color contrast values in Theme.swift for WCAG AA compliance - Extract CloudKitContainerConfig for explicit container identity - Remove PostHog debug console log from AnalyticsManager Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
72 lines
1.9 KiB
Swift
72 lines
1.9 KiB
Swift
import Testing
|
|
import Foundation
|
|
@testable import SportsTime
|
|
|
|
@Suite("PollVotingViewModel")
|
|
@MainActor
|
|
struct PollVotingViewModelTests {
|
|
|
|
@Test("initializeRankings defaults to original trip order")
|
|
func initializeRankings_defaultOrder() {
|
|
let viewModel = PollVotingViewModel()
|
|
|
|
viewModel.initializeRankings(tripCount: 5, existingVote: nil)
|
|
|
|
#expect(viewModel.rankings == [0, 1, 2, 3, 4])
|
|
}
|
|
|
|
@Test("initializeRankings uses existing vote order")
|
|
func initializeRankings_existingVoteOrder() {
|
|
let viewModel = PollVotingViewModel()
|
|
let existingVote = PollVote(
|
|
pollId: UUID(),
|
|
odg: "user_123",
|
|
rankings: [2, 0, 3, 1]
|
|
)
|
|
|
|
viewModel.initializeRankings(tripCount: 4, existingVote: existingVote)
|
|
|
|
#expect(viewModel.rankings == [2, 0, 3, 1])
|
|
}
|
|
|
|
@Test("moveTripUp swaps with previous item")
|
|
func moveTripUp_swapsWithPrevious() {
|
|
let viewModel = PollVotingViewModel()
|
|
viewModel.rankings = [0, 1, 2, 3]
|
|
|
|
viewModel.moveTripUp(at: 2)
|
|
|
|
#expect(viewModel.rankings == [0, 2, 1, 3])
|
|
}
|
|
|
|
@Test("moveTripDown swaps with next item")
|
|
func moveTripDown_swapsWithNext() {
|
|
let viewModel = PollVotingViewModel()
|
|
viewModel.rankings = [0, 1, 2, 3]
|
|
|
|
viewModel.moveTripDown(at: 1)
|
|
|
|
#expect(viewModel.rankings == [0, 2, 1, 3])
|
|
}
|
|
|
|
@Test("moveTripUp is no-op at first index")
|
|
func moveTripUp_firstIndexNoOp() {
|
|
let viewModel = PollVotingViewModel()
|
|
viewModel.rankings = [0, 1, 2]
|
|
|
|
viewModel.moveTripUp(at: 0)
|
|
|
|
#expect(viewModel.rankings == [0, 1, 2])
|
|
}
|
|
|
|
@Test("moveTripDown is no-op at last index")
|
|
func moveTripDown_lastIndexNoOp() {
|
|
let viewModel = PollVotingViewModel()
|
|
viewModel.rankings = [0, 1, 2]
|
|
|
|
viewModel.moveTripDown(at: 2)
|
|
|
|
#expect(viewModel.rankings == [0, 1, 2])
|
|
}
|
|
}
|