Browse Source

Add calendar to tests.

master
Abhishek Banthia 1 year ago
parent
commit
6605d55507
  1. 4
      Clocker/ClockerUnitTests/StandardMenubarHandlerTests.swift
  2. 2
      Clocker/Events and Reminders/CalendarHandler.swift

4
Clocker/ClockerUnitTests/StandardMenubarHandlerTests.swift

@ -184,6 +184,7 @@ class StandardMenubarHandlerTests: XCTestCase {
let futureChunk = TimeChunk(seconds: 10, minutes: 5, hours: 0, days: 0, weeks: 0, months: 0, years: 0) let futureChunk = TimeChunk(seconds: 10, minutes: 5, hours: 0, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore) let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Event happening" mockEvent.title = "Event happening"
mockEvent.calendar = EKCalendar(for: .event, eventStore: eventStore)
mockEvent.startDate = Date().add(futureChunk) mockEvent.startDate = Date().add(futureChunk)
let eventInfo = EventInfo(event: mockEvent, let eventInfo = EventInfo(event: mockEvent,
isAllDay: false, isAllDay: false,
@ -204,6 +205,7 @@ class StandardMenubarHandlerTests: XCTestCase {
let futureChunk = TimeChunk(seconds: 10, minutes: 29, hours: 0, days: 0, weeks: 0, months: 0, years: 0) let futureChunk = TimeChunk(seconds: 10, minutes: 29, hours: 0, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore) let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Event happening" mockEvent.title = "Event happening"
mockEvent.calendar = EKCalendar(for: .event, eventStore: eventStore)
mockEvent.startDate = Date().add(futureChunk) mockEvent.startDate = Date().add(futureChunk)
let eventInfo = EventInfo(event: mockEvent, let eventInfo = EventInfo(event: mockEvent,
isAllDay: false, isAllDay: false,
@ -224,6 +226,7 @@ class StandardMenubarHandlerTests: XCTestCase {
let futureChunk = TimeChunk(seconds: 10, minutes: 31, hours: 0, days: 0, weeks: 0, months: 0, years: 0) let futureChunk = TimeChunk(seconds: 10, minutes: 31, hours: 0, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore) let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Event happening" mockEvent.title = "Event happening"
mockEvent.calendar = EKCalendar(for: .event, eventStore: eventStore)
mockEvent.startDate = Date().add(futureChunk) mockEvent.startDate = Date().add(futureChunk)
let eventInfo = EventInfo(event: mockEvent, let eventInfo = EventInfo(event: mockEvent,
isAllDay: false, isAllDay: false,
@ -242,6 +245,7 @@ class StandardMenubarHandlerTests: XCTestCase {
let futureChunk = TimeChunk(seconds: 10, minutes: 31, hours: 0, days: 0, weeks: 0, months: 0, years: 0) let futureChunk = TimeChunk(seconds: 10, minutes: 31, hours: 0, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore) let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.startDate = Date().add(futureChunk) mockEvent.startDate = Date().add(futureChunk)
mockEvent.calendar = EKCalendar(for: .event, eventStore: eventStore)
let eventInfo = EventInfo(event: mockEvent, let eventInfo = EventInfo(event: mockEvent,
isAllDay: false, isAllDay: false,
meetingURL: nil, meetingURL: nil,

2
Clocker/Events and Reminders/CalendarHandler.swift

@ -22,11 +22,9 @@ extension EventCenter {
// Fetch array of user's calendars sorted first by source title and then by calendar title // Fetch array of user's calendars sorted first by source title and then by calendar title
let calendars = eventStore.calendars(for: .event).sorted { cal1, cal2 -> Bool in let calendars = eventStore.calendars(for: .event).sorted { cal1, cal2 -> Bool in
if cal1.source.sourceIdentifier == cal2.source.sourceIdentifier { if cal1.source.sourceIdentifier == cal2.source.sourceIdentifier {
return cal1.title < cal2.title return cal1.title < cal2.title
} }
return cal1.source.title < cal2.source.title return cal1.source.title < cal2.source.title
} }

Loading…
Cancel
Save