Skip to content

Commit

Permalink
Add tests for private API hack (#51)
Browse files Browse the repository at this point in the history
Testing 9254fe8
  • Loading branch information
keith authored Dec 15, 2022
1 parent 9254fe8 commit 849de54
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Tests/RemindersTests/NaturalLanguageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,30 @@ final class NaturalLanguageTests: XCTestCase {
XCTAssertEqual(components, expectedComponents)
}

func testTodayString() throws {
let components = try XCTUnwrap(DateComponents(argument: "today"))
let expectedComponents = Calendar.current.dateComponents(
calendarComponents(except: timeComponents), from: Date())

XCTAssertEqual(components, expectedComponents)
}

func testTodayNoon() throws {
let components = try XCTUnwrap(DateComponents(argument: "12:00"))
let today = try XCTUnwrap(Calendar.current.date(bySettingHour: 12, minute: 0, second: 0, of: Date()))
let expectedComponents = Calendar.current.dateComponents(calendarComponents(), from: today)

XCTAssertEqual(components, expectedComponents)
}

func testTonight() throws {
let components = try XCTUnwrap(DateComponents(argument: "tonight"))
let today = try XCTUnwrap(Calendar.current.date(bySettingHour: 19, minute: 0, second: 0, of: Date()))
let expectedComponents = Calendar.current.dateComponents(calendarComponents(), from: today)

XCTAssertEqual(components, expectedComponents)
}

func testTomorrow() throws {
let components = try XCTUnwrap(DateComponents(argument: "tomorrow"))
let tomorrow = try XCTUnwrap(Calendar.current.date(byAdding: .day, value: 1, to: Date()))
Expand Down

0 comments on commit 849de54

Please sign in to comment.