SoliCards-iOS-iPadOS-MacOS/SoliCardsTests/Models/CardTests.swift
idev2025 de0da01f25 feat: SoliCards v1.2.0 — native SwiftUI solitaire for iOS, iPadOS, macOS
Complete native rewrite of the web-based SoliCards game as a SwiftUI
multiplatform app targeting iOS 17+, iPadOS 17+, and macOS 14+.

Three solitaire variants (Klondike, Spider, FreeCell) with full game
rules, drag & drop, smart zoom layout, 6 themes, 4 difficulty levels,
SwiftData persistence, VoiceOver accessibility, and 57 unit tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 08:26:14 -04:00

41 lines
1.2 KiB
Swift

import Testing
@testable import SoliCards
@Suite("Card Model Tests")
struct CardTests {
@Test("Card color matches suit")
func cardColor() {
let redCard = Card(suit: .hearts, rank: .ace)
let blackCard = Card(suit: .spades, rank: .king)
#expect(redCard.color == .red)
#expect(blackCard.color == .black)
}
@Test("Card accessibility description")
func accessibilityDescription() {
let faceUp = Card(suit: .diamonds, rank: .queen, isFaceUp: true)
let faceDown = Card(suit: .clubs, rank: .two, isFaceUp: false)
#expect(faceUp.accessibilityDescription == "Queen of Diamonds")
#expect(faceDown.accessibilityDescription == "Card, face down")
}
@Test("Card identity")
func uniqueIdentity() {
let card1 = Card(suit: .spades, rank: .ace)
let card2 = Card(suit: .spades, rank: .ace)
// Same suit/rank but different IDs
#expect(card1.id != card2.id)
}
@Test("Front image name")
func frontImageName() {
let card = Card(suit: .hearts, rank: .king)
#expect(card.frontImageName(style: .classic) == "classic_hearts_king")
#expect(card.frontImageName(style: .modern) == "modern_hearts_king")
}
}