4761e2e5c8
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.5 KiB
Swift
51 lines
1.5 KiB
Swift
import XCTest
|
|
@testable import PortfolioJournal
|
|
|
|
@MainActor
|
|
final class GoalsDisplayRulesTests: XCTestCase {
|
|
func testIsAchievedProgressThreshold() {
|
|
XCTAssertFalse(GoalsViewModel.isAchieved(progress: 0.998))
|
|
XCTAssertTrue(GoalsViewModel.isAchieved(progress: 0.999))
|
|
XCTAssertTrue(GoalsViewModel.isAchieved(progress: 1.0))
|
|
}
|
|
|
|
func testUrgencyLevelIsCriticalWhenBehindAndPastTargetDate() {
|
|
let targetDate = Date(timeIntervalSince1970: 1_000_000)
|
|
let referenceDate = Date(timeIntervalSince1970: 1_100_000)
|
|
|
|
let level = GoalsViewModel.urgencyLevel(
|
|
targetDate: targetDate,
|
|
isBehind: true,
|
|
isAchieved: false,
|
|
referenceDate: referenceDate
|
|
)
|
|
|
|
XCTAssertEqual(level, .critical)
|
|
}
|
|
|
|
func testUrgencyLevelIsWarningWhenBehindBeforeTargetDate() {
|
|
let targetDate = Date(timeIntervalSince1970: 1_100_000)
|
|
let referenceDate = Date(timeIntervalSince1970: 1_000_000)
|
|
|
|
let level = GoalsViewModel.urgencyLevel(
|
|
targetDate: targetDate,
|
|
isBehind: true,
|
|
isAchieved: false,
|
|
referenceDate: referenceDate
|
|
)
|
|
|
|
XCTAssertEqual(level, .warning)
|
|
}
|
|
|
|
func testUrgencyLevelIsNormalForAchievedGoals() {
|
|
let level = GoalsViewModel.urgencyLevel(
|
|
targetDate: Date(),
|
|
isBehind: true,
|
|
isAchieved: true,
|
|
referenceDate: Date().addingTimeInterval(86_400)
|
|
)
|
|
|
|
XCTAssertEqual(level, .normal)
|
|
}
|
|
}
|