|
|
@ -67,7 +67,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
let store = makeMockStore() |
|
|
|
let store = makeMockStore() |
|
|
|
// Wipe all timezones from UserDefaults |
|
|
|
// Wipe all timezones from UserDefaults |
|
|
|
store.setTimezones(nil) |
|
|
|
store.setTimezones(nil) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
let emptyMenubarString = menubarHandler.titleForMenubar() |
|
|
|
let emptyMenubarString = menubarHandler.titleForMenubar() |
|
|
|
// Returns early because DataStore.menubarTimezones is nil |
|
|
|
// Returns early because DataStore.menubarTimezones is nil |
|
|
|
XCTAssertNil(emptyMenubarString) |
|
|
|
XCTAssertNil(emptyMenubarString) |
|
|
@ -86,7 +86,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
func testWithEmptyMenubarTimezones() { |
|
|
|
func testWithEmptyMenubarTimezones() { |
|
|
|
let store = makeMockStore() |
|
|
|
let store = makeMockStore() |
|
|
|
store.setTimezones(nil) |
|
|
|
store.setTimezones(nil) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
XCTAssertNil(menubarHandler.titleForMenubar()) |
|
|
|
XCTAssertNil(menubarHandler.titleForMenubar()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -98,7 +98,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
dataObject.isFavourite = 1 |
|
|
|
dataObject.isFavourite = 1 |
|
|
|
saveObject(object: dataObject, in: store) |
|
|
|
saveObject(object: dataObject, in: store) |
|
|
|
|
|
|
|
|
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
XCTAssertNil(menubarHandler.titleForMenubar()) |
|
|
|
XCTAssertNil(menubarHandler.titleForMenubar()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -110,7 +110,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
dataObject.isFavourite = 1 |
|
|
|
dataObject.isFavourite = 1 |
|
|
|
saveObject(object: dataObject, in: store) |
|
|
|
saveObject(object: dataObject, in: store) |
|
|
|
|
|
|
|
|
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
XCTAssertNotNil(menubarHandler.titleForMenubar()) |
|
|
|
XCTAssertNotNil(menubarHandler.titleForMenubar()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -122,7 +122,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
mockEvent.title = "Mock Title" |
|
|
|
mockEvent.title = "Mock Title" |
|
|
|
mockEvent.startDate = Date().add(futureChunk) |
|
|
|
mockEvent.startDate = Date().add(futureChunk) |
|
|
|
|
|
|
|
|
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
XCTAssert(menubarHandler.format(event: mockEvent) == "Mock Title in 10m", |
|
|
|
XCTAssert(menubarHandler.format(event: mockEvent) == "Mock Title in 10m", |
|
|
|
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation") |
|
|
|
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation") |
|
|
|
} |
|
|
|
} |
|
|
@ -135,7 +135,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
mockEvent.title = "Mock Title" |
|
|
|
mockEvent.title = "Mock Title" |
|
|
|
mockEvent.startDate = Date().add(futureChunk) |
|
|
|
mockEvent.startDate = Date().add(futureChunk) |
|
|
|
|
|
|
|
|
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
XCTAssert(menubarHandler.format(event: mockEvent) == "Mock Title in 1m", |
|
|
|
XCTAssert(menubarHandler.format(event: mockEvent) == "Mock Title in 1m", |
|
|
|
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation") |
|
|
|
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation") |
|
|
|
} |
|
|
|
} |
|
|
@ -148,7 +148,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
mockEvent.title = "Mock Title" |
|
|
|
mockEvent.title = "Mock Title" |
|
|
|
mockEvent.startDate = Date().add(futureChunk) |
|
|
|
mockEvent.startDate = Date().add(futureChunk) |
|
|
|
|
|
|
|
|
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
XCTAssert(menubarHandler.format(event: mockEvent) == "Mock Title starts now.", |
|
|
|
XCTAssert(menubarHandler.format(event: mockEvent) == "Mock Title starts now.", |
|
|
|
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation") |
|
|
|
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation") |
|
|
|
} |
|
|
|
} |
|
|
@ -160,7 +160,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
let mockEvent = EKEvent(eventStore: eventStore) |
|
|
|
let mockEvent = EKEvent(eventStore: eventStore) |
|
|
|
mockEvent.startDate = Date().add(futureChunk) |
|
|
|
mockEvent.startDate = Date().add(futureChunk) |
|
|
|
|
|
|
|
|
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
XCTAssert(menubarHandler.format(event: mockEvent) == CLEmptyString, |
|
|
|
XCTAssert(menubarHandler.format(event: mockEvent) == CLEmptyString, |
|
|
|
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation") |
|
|
|
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation") |
|
|
|
} |
|
|
|
} |
|
|
@ -173,7 +173,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
mockEvent.title = "Really long calendar event title that longer than the longest name" |
|
|
|
mockEvent.title = "Really long calendar event title that longer than the longest name" |
|
|
|
mockEvent.startDate = Date().add(futureChunk) |
|
|
|
mockEvent.startDate = Date().add(futureChunk) |
|
|
|
|
|
|
|
|
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
XCTAssert(menubarHandler.format(event: mockEvent) == "Really long calendar event tit... starts now.", |
|
|
|
XCTAssert(menubarHandler.format(event: mockEvent) == "Really long calendar event tit... starts now.", |
|
|
|
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation") |
|
|
|
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation") |
|
|
|
} |
|
|
|
} |
|
|
@ -190,7 +190,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
meetingURL: nil, |
|
|
|
meetingURL: nil, |
|
|
|
attendeStatus: .accepted) |
|
|
|
attendeStatus: .accepted) |
|
|
|
|
|
|
|
|
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
let calendar = Calendar.autoupdatingCurrent |
|
|
|
let calendar = Calendar.autoupdatingCurrent |
|
|
|
let events: [Date: [EventInfo]] = [calendar.startOfDay(for: Date()): [eventInfo]] |
|
|
|
let events: [Date: [EventInfo]] = [calendar.startOfDay(for: Date()): [eventInfo]] |
|
|
|
let actualResult = try XCTUnwrap(menubarHandler.checkForUpcomingEvents(events, calendar: calendar)) |
|
|
|
let actualResult = try XCTUnwrap(menubarHandler.checkForUpcomingEvents(events, calendar: calendar)) |
|
|
@ -210,7 +210,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
meetingURL: nil, |
|
|
|
meetingURL: nil, |
|
|
|
attendeStatus: .accepted) |
|
|
|
attendeStatus: .accepted) |
|
|
|
|
|
|
|
|
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
let calendar = Calendar.autoupdatingCurrent |
|
|
|
let calendar = Calendar.autoupdatingCurrent |
|
|
|
let events: [Date: [EventInfo]] = [calendar.startOfDay(for: Date()): [eventInfo]] |
|
|
|
let events: [Date: [EventInfo]] = [calendar.startOfDay(for: Date()): [eventInfo]] |
|
|
|
let actualResult = try XCTUnwrap(menubarHandler.checkForUpcomingEvents(events, calendar: calendar)) |
|
|
|
let actualResult = try XCTUnwrap(menubarHandler.checkForUpcomingEvents(events, calendar: calendar)) |
|
|
@ -230,7 +230,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
meetingURL: nil, |
|
|
|
meetingURL: nil, |
|
|
|
attendeStatus: .accepted) |
|
|
|
attendeStatus: .accepted) |
|
|
|
|
|
|
|
|
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
let calendar = Calendar.autoupdatingCurrent |
|
|
|
let calendar = Calendar.autoupdatingCurrent |
|
|
|
let events: [Date: [EventInfo]] = [calendar.startOfDay(for: Date()): [eventInfo]] |
|
|
|
let events: [Date: [EventInfo]] = [calendar.startOfDay(for: Date()): [eventInfo]] |
|
|
|
XCTAssertNil(menubarHandler.checkForUpcomingEvents(events, calendar: calendar)) |
|
|
|
XCTAssertNil(menubarHandler.checkForUpcomingEvents(events, calendar: calendar)) |
|
|
@ -247,7 +247,7 @@ class StandardMenubarHandlerTests: XCTestCase { |
|
|
|
meetingURL: nil, |
|
|
|
meetingURL: nil, |
|
|
|
attendeStatus: .accepted) |
|
|
|
attendeStatus: .accepted) |
|
|
|
|
|
|
|
|
|
|
|
let menubarHandler = MenubarTitleProvider(with: store) |
|
|
|
let menubarHandler = MenubarTitleProvider(with: store, eventStore: EventCenter.sharedCenter()) |
|
|
|
let calendar = Calendar.autoupdatingCurrent |
|
|
|
let calendar = Calendar.autoupdatingCurrent |
|
|
|
let events: [Date: [EventInfo]] = [calendar.startOfDay(for: Date()): [eventInfo]] |
|
|
|
let events: [Date: [EventInfo]] = [calendar.startOfDay(for: Date()): [eventInfo]] |
|
|
|
XCTAssertNil(menubarHandler.checkForUpcomingEvents(events, calendar: calendar)) |
|
|
|
XCTAssertNil(menubarHandler.checkForUpcomingEvents(events, calendar: calendar)) |
|
|
|