This commit adds extensive unit test coverage for the entire application, including iOS ViewModels, design system, and shared Kotlin Multiplatform code. iOS Unit Tests (49 tests): - LoginViewModelTests: Authentication state and validation tests - ResidenceViewModelTests: Residence loading and state management - TaskViewModelTests: Task operations (cancel, archive, mark progress) - DocumentViewModelTests: Document/warranty CRUD operations - ContractorViewModelTests: Contractor management and favorites - DesignSystemTests: Color system, typography, spacing, radius, shadows Shared KMM Unit Tests (26 tests): - AuthViewModelTest: Login, register, verify email state initialization - TaskViewModelTest: Task state management verification - DocumentViewModelTest: Document state initialization tests - ResidenceViewModelTest: Residence state management tests - ContractorViewModelTest: Contractor state initialization tests Test Infrastructure: - Reorganized test files from iosAppUITests to MyCribTests - All shared KMM tests passing successfully (./gradlew test) - Tests focus on state initialization and core functionality - Ready for CI/CD integration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
173 lines
4.4 KiB
Swift
173 lines
4.4 KiB
Swift
import XCTest
|
|
@testable import iosApp
|
|
import SwiftUI
|
|
|
|
final class DesignSystemTests: XCTestCase {
|
|
|
|
// MARK: - Color Tests
|
|
|
|
func testPrimaryColorsExist() {
|
|
// Then
|
|
XCTAssertNotNil(AppColors.primary)
|
|
XCTAssertNotNil(AppColors.primaryLight)
|
|
XCTAssertNotNil(AppColors.primaryDark)
|
|
}
|
|
|
|
func testAccentColorsExist() {
|
|
// Then
|
|
XCTAssertNotNil(AppColors.accent)
|
|
XCTAssertNotNil(AppColors.accentLight)
|
|
}
|
|
|
|
func testSemanticColorsExist() {
|
|
// Then
|
|
XCTAssertNotNil(AppColors.success)
|
|
XCTAssertNotNil(AppColors.warning)
|
|
XCTAssertNotNil(AppColors.error)
|
|
XCTAssertNotNil(AppColors.info)
|
|
}
|
|
|
|
func testNeutralColorsExist() {
|
|
// Then
|
|
XCTAssertNotNil(AppColors.background)
|
|
XCTAssertNotNil(AppColors.surface)
|
|
XCTAssertNotNil(AppColors.surfaceSecondary)
|
|
XCTAssertNotNil(AppColors.textPrimary)
|
|
XCTAssertNotNil(AppColors.textSecondary)
|
|
XCTAssertNotNil(AppColors.textTertiary)
|
|
XCTAssertNotNil(AppColors.border)
|
|
XCTAssertNotNil(AppColors.borderLight)
|
|
}
|
|
|
|
func testTaskStatusColorsExist() {
|
|
// Then
|
|
XCTAssertNotNil(AppColors.taskUpcoming)
|
|
XCTAssertNotNil(AppColors.taskInProgress)
|
|
XCTAssertNotNil(AppColors.taskCompleted)
|
|
XCTAssertNotNil(AppColors.taskCanceled)
|
|
XCTAssertNotNil(AppColors.taskArchived)
|
|
}
|
|
|
|
func testGradientsExist() {
|
|
// Then
|
|
XCTAssertNotNil(AppColors.primaryGradient)
|
|
XCTAssertNotNil(AppColors.accentGradient)
|
|
}
|
|
|
|
// MARK: - Typography Tests
|
|
|
|
func testDisplayTypographyExists() {
|
|
// Then
|
|
XCTAssertNotNil(AppTypography.displayLarge)
|
|
XCTAssertNotNil(AppTypography.displayMedium)
|
|
XCTAssertNotNil(AppTypography.displaySmall)
|
|
}
|
|
|
|
func testHeadlineTypographyExists() {
|
|
// Then
|
|
XCTAssertNotNil(AppTypography.headlineLarge)
|
|
XCTAssertNotNil(AppTypography.headlineMedium)
|
|
XCTAssertNotNil(AppTypography.headlineSmall)
|
|
}
|
|
|
|
func testTitleTypographyExists() {
|
|
// Then
|
|
XCTAssertNotNil(AppTypography.titleLarge)
|
|
XCTAssertNotNil(AppTypography.titleMedium)
|
|
XCTAssertNotNil(AppTypography.titleSmall)
|
|
}
|
|
|
|
func testBodyTypographyExists() {
|
|
// Then
|
|
XCTAssertNotNil(AppTypography.bodyLarge)
|
|
XCTAssertNotNil(AppTypography.bodyMedium)
|
|
XCTAssertNotNil(AppTypography.bodySmall)
|
|
}
|
|
|
|
func testLabelTypographyExists() {
|
|
// Then
|
|
XCTAssertNotNil(AppTypography.labelLarge)
|
|
XCTAssertNotNil(AppTypography.labelMedium)
|
|
XCTAssertNotNil(AppTypography.labelSmall)
|
|
}
|
|
|
|
// MARK: - Spacing Tests
|
|
|
|
func testSpacingValuesAreCorrect() {
|
|
// Then
|
|
XCTAssertEqual(AppSpacing.xxs, 4)
|
|
XCTAssertEqual(AppSpacing.xs, 8)
|
|
XCTAssertEqual(AppSpacing.sm, 12)
|
|
XCTAssertEqual(AppSpacing.md, 16)
|
|
XCTAssertEqual(AppSpacing.lg, 24)
|
|
XCTAssertEqual(AppSpacing.xl, 32)
|
|
XCTAssertEqual(AppSpacing.xxl, 48)
|
|
XCTAssertEqual(AppSpacing.xxxl, 64)
|
|
}
|
|
|
|
// MARK: - Radius Tests
|
|
|
|
func testRadiusValuesAreCorrect() {
|
|
// Then
|
|
XCTAssertEqual(AppRadius.xs, 4)
|
|
XCTAssertEqual(AppRadius.sm, 8)
|
|
XCTAssertEqual(AppRadius.md, 12)
|
|
XCTAssertEqual(AppRadius.lg, 16)
|
|
XCTAssertEqual(AppRadius.xl, 20)
|
|
XCTAssertEqual(AppRadius.xxl, 24)
|
|
XCTAssertEqual(AppRadius.full, 9999)
|
|
}
|
|
|
|
// MARK: - Shadow Tests
|
|
|
|
func testShadowsExist() {
|
|
// Then
|
|
XCTAssertNotNil(AppShadow.sm)
|
|
XCTAssertNotNil(AppShadow.md)
|
|
XCTAssertNotNil(AppShadow.lg)
|
|
XCTAssertNotNil(AppShadow.xl)
|
|
}
|
|
|
|
// MARK: - Color Extension Tests
|
|
|
|
func testColorFromValidHexString() {
|
|
// When
|
|
let color = Color(hex: "FF0000")
|
|
|
|
// Then
|
|
XCTAssertNotNil(color)
|
|
}
|
|
|
|
func testColorFromInvalidHexString() {
|
|
// When
|
|
let color = Color(hex: "INVALID")
|
|
|
|
// Then
|
|
XCTAssertNil(color)
|
|
}
|
|
|
|
func testColorFrom3DigitHex() {
|
|
// When
|
|
let color = Color(hex: "F00")
|
|
|
|
// Then
|
|
XCTAssertNotNil(color)
|
|
}
|
|
|
|
func testColorFrom6DigitHex() {
|
|
// When
|
|
let color = Color(hex: "FF0000")
|
|
|
|
// Then
|
|
XCTAssertNotNil(color)
|
|
}
|
|
|
|
func testColorFrom8DigitHex() {
|
|
// When
|
|
let color = Color(hex: "FF0000FF")
|
|
|
|
// Then
|
|
XCTAssertNotNil(color)
|
|
}
|
|
}
|