Skip to content

Commit 4084532

Browse files
authored
[CoreInternal] Add regression test for fix in #11611 (#11613)
1 parent 2cdbbb7 commit 4084532

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

FirebaseCore/Internal/Tests/Unit/HeartbeatsPayloadTests.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class HeartbeatsPayloadTests: XCTestCase {
2727
)
2828
}
2929

30-
func testDateFormatterUses_YYYY_MM_dd_Format() throws {
30+
func testDateFormatterUses_yyyy_MM_dd_Format() throws {
3131
// Given
3232
let date = Date(timeIntervalSince1970: 1_635_739_200) // 2021-11-01
3333
// When
@@ -36,6 +36,17 @@ class HeartbeatsPayloadTests: XCTestCase {
3636
XCTAssertEqual(dateString, "2021-11-01")
3737
}
3838

39+
func testDateFormatterDoesNotUseWeekYear() throws {
40+
// Given
41+
// The "week year" of `2018-12-31` is 2019, so we want to ensure that such
42+
// dates are formatted using the "calendar year" (2018).
43+
let date = Date(timeIntervalSince1970: 1_546_275_600) // 2018-12-31
44+
// When
45+
let dateString = HeartbeatsPayload.dateFormatter.string(from: date)
46+
// Then
47+
XCTAssertEqual(dateString, "2018-12-31")
48+
}
49+
3950
func testEncodeAndDecode() throws {
4051
// Given
4152
let heartbeatsPayload = HeartbeatsPayload(

0 commit comments

Comments
 (0)