extension NSDate {
class func todayDateFromMidnightForSeconds(seconds: NSTimeInterval) -> NSDate {
let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
let startOfTheCurrentDay = calendar.startOfDayForDate(NSDate())
return startOfTheCurrentDay.dateByAddingTimeInterval(seconds)
}
}
How can I mock my NSDate()
inside my custom method to test it in a proper way?
You just need to delete "class" declaration from your method and replace NSDate() with self as follow: