import XCTest
@testable import PortfolioJournal

final class MonthlyCheckInViewTests: XCTestCase {
    func testMonthLabelUsesMonthAndYear() {
        var components = DateComponents()
        components.year = 2026
        components.month = 2
        components.day = 1
        let date = Calendar(identifier: .gregorian).date(from: components)!

        let label = MonthlyCheckInView.monthLabel(
            for: date,
            relativeTo: date,
            locale: Locale(identifier: "en_US_POSIX")
        )

        XCTAssertEqual(label, "February 2026")
    }

    func testMonthLabelUsesPreviousMonthDuringGracePeriod() {
        var components = DateComponents()
        components.year = 2026
        components.month = 2
        components.day = 20
        let date = Calendar(identifier: .gregorian).date(from: components)!

        let label = MonthlyCheckInView.monthLabel(
            for: date,
            relativeTo: date,
            locale: Locale(identifier: "en_US_POSIX")
        )

        XCTAssertEqual(label, "January 2026")
    }
}
