@@ -56,22 +56,26 @@ class NSDateHelperTest: XCTestCase {
5656 }
5757
5858 /// Verifies that `mediumStringWithTime` takes into account the time zone adjustment
59- /// If this test is failing, check that the Test Plan is still using en-US as its language
59+ ///
60+ /// This legacy test is a bit silly because it is simply testing that the code calls `DateFormatter` with the expected configuration.
61+ /// This was done to make the test robust against underlying changes in `DateFormatter`'s behavior.
62+ /// Example failure this avoids: https://buildkite.com/automattic/wordpress-shared-ios/builds/235#018ed45e-c2be-40e5-9759-6bd7c0735ce9/6-2623
6063 func testMediumStringTimeZoneAdjust( ) {
6164 let date = Date ( )
6265 let timeZone = TimeZone ( secondsFromGMT: Calendar . current. timeZone. secondsFromGMT ( ) - ( 60 * 60 ) )
6366 XCTAssertEqual ( date. toMediumString ( inTimeZone: timeZone) , " now " )
6467
6568 let timeFormatter = DateFormatter ( )
66- timeFormatter. dateStyle = . none
69+ timeFormatter. doesRelativeDateFormatting = true
70+ timeFormatter. dateStyle = . medium
6771 timeFormatter. timeStyle = . short
6872 let withoutTimeZoneAdjust = timeFormatter. string ( from: date)
6973
70- XCTAssertEqual ( date. mediumStringWithTime ( ) , " Today, \( withoutTimeZoneAdjust) " )
74+ XCTAssertEqual ( date. mediumStringWithTime ( ) , withoutTimeZoneAdjust)
7175
7276 timeFormatter. timeZone = timeZone
7377 let withTimeZoneAdjust = timeFormatter. string ( from: date)
7478
75- XCTAssertEqual ( date. mediumStringWithTime ( timeZone: timeZone) , " Today, \( withTimeZoneAdjust) " )
79+ XCTAssertEqual ( date. mediumStringWithTime ( timeZone: timeZone) , withTimeZoneAdjust)
7680 }
7781}
0 commit comments