import XCTest
@testable import MealMood

final class DateHelpersTests: XCTestCase {

    func testStartOfWeekReturnsMonday() {
        var components = DateComponents()
        components.year = 2026
        components.month = 2
        components.day = 18 // Wednesday
        let calendar = Calendar(identifier: .gregorian)
        let input = calendar.date(from: components)!

        let start = input.startOfWeek()
        let weekday = calendar.component(.weekday, from: start)

        XCTAssertEqual(weekday, 2) // Monday in Gregorian calendar
    }

    func testCombineDateAndTime() {
        let calendar = Calendar(identifier: .gregorian)

        let date = calendar.date(from: DateComponents(year: 2026, month: 2, day: 20))!
        let time = calendar.date(from: DateComponents(hour: 21, minute: 30))!

        let combined = combineDateAndTime(date: date, time: time)
        let parts = calendar.dateComponents([.year, .month, .day, .hour, .minute], from: combined)

        XCTAssertEqual(parts.year, 2026)
        XCTAssertEqual(parts.month, 2)
        XCTAssertEqual(parts.day, 20)
        XCTAssertEqual(parts.hour, 21)
        XCTAssertEqual(parts.minute, 30)
    }
}

