Merge pull request #437 from zhongwuzw/fix-tests

Fix tests failure when last week is the last year
This commit is contained in:
Steven Deutsch
2018-01-02 12:45:53 -06:00
committed by GitHub
@@ -93,7 +93,13 @@ class MessageKitDateFormatterTests: XCTestCase {
///Day of last week
startOfWeek = (Calendar.current as NSCalendar).date(byAdding: .day, value: -2, to: startOfWeek, options: [])!
formatter.dateFormat = "E, d MMM, h:mm a"
if Calendar.current.isDate(startOfWeek, equalTo: Date(), toGranularity: .year) {
formatter.dateFormat = "E, d MMM, h:mm a"
} else {
formatter.dateFormat = "MMM d, yyyy, h:mm a"
}
XCTAssertEqual(MessageKitDateFormatter.shared.string(from: startOfWeek), formatter.string(from: startOfWeek))
}