4761e2e5c8
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
27 lines
1.1 KiB
Swift
27 lines
1.1 KiB
Swift
import XCTest
|
|
@testable import PortfolioJournal
|
|
|
|
@MainActor
|
|
final class ChartsViewModelDisplayRulesTests: XCTestCase {
|
|
func testAllocationTargetsSupportedOnlyForCategoryBreakdown() {
|
|
XCTAssertTrue(ChartsViewModel.supportsAllocationTargets(for: .category))
|
|
XCTAssertFalse(ChartsViewModel.supportsAllocationTargets(for: .source))
|
|
}
|
|
|
|
func testEvolutionTimeRangesIncludeRequestedOptions() {
|
|
let viewModel = ChartsViewModel(iapService: IAPService())
|
|
let ranges = viewModel.availableTimeRanges(for: .evolution)
|
|
|
|
XCTAssertEqual(ranges, [.all, .yearToDate, .year, .quarter])
|
|
}
|
|
|
|
func testYearToDateRangeStartsAtBeginningOfYear() {
|
|
let calendar = Calendar(identifier: .gregorian)
|
|
let referenceDate = calendar.date(from: DateComponents(year: 2026, month: 8, day: 15))!
|
|
let startDate = ChartsViewModel.TimeRange.yearToDate.startDate(referenceDate: referenceDate)
|
|
let expected = calendar.date(from: DateComponents(year: 2026, month: 1, day: 1))!
|
|
|
|
XCTAssertEqual(startDate, expected)
|
|
}
|
|
}
|