43 lines · 1.6 KB · SwiftRaw
@testable import CottonUIimport CottonValuesimport XCTest/// RULE: the event card's clock shows the event's start — its hands read off/// the clock words the core said after the date's join, the hour hand walking/// with the minutes — and a day with no clock (an all-day event) draws no/// hands (faces lane, 23 Oct 2026).final class EventClockHandsTests: XCTestCase { private func hands(_ date: String) -> (hour: Double, minute: Double)? { EventHands.angles(EventWhen(date).clock) } func testThreeOClockPointsAtThreeAndTwelve() throws { let three = try XCTUnwrap(hands("Fri 23 Oct \u{00B7} 3:00 pm")) XCTAssertEqual(three.hour, 90) XCTAssertEqual(three.minute, 0) } func testHalfPastTwoSitsHalfwayToThree() throws { let half = try XCTUnwrap(hands("Thu 29 Oct \u{00B7} 2:30 am")) XCTAssertEqual(half.hour, 75) XCTAssertEqual(half.minute, 180) } func testTheHalfOfTheDayIsReadAndTwelveIsNoughtOrNoon() { XCTAssertEqual(EventHands.time("7:30 pm"), ClockTime(hour: 19, minute: 30)) XCTAssertEqual(EventHands.time("12:05 am"), ClockTime(hour: 0, minute: 5)) XCTAssertEqual(EventHands.time("12:45 pm"), ClockTime(hour: 12, minute: 45)) XCTAssertEqual(EventHands.angles("12:45 pm")?.hour, 22.5) } func testAnAllDayEventDrawsNoHands() { XCTAssertNil(EventWhen("Thu 29 Oct").clock) XCTAssertNil(hands("Thu 29 Oct")) XCTAssertNil(hands("Today")) } func testWordsThatAreNoClockDrawNoHands() { XCTAssertNil(EventHands.angles("half past four")) XCTAssertNil(EventHands.angles("14:30")) }}