Skip to content

Commit

Permalink
test: date formatter in tests iOS18 (#168)
Browse files Browse the repository at this point in the history
Release-As: 1.0.0
  • Loading branch information
fabriziodemaria authored Nov 5, 2024
1 parent df2c37f commit 9cab6bb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Tests/ConfidenceProviderTests/ConfidenceTypeMapperTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ValueConverterTest: XCTestCase {

func testContextConversionWithLists() throws {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let date1 = try XCTUnwrap(formatter.date(from: "2022-01-01 12:00:00"))
let date2 = try XCTUnwrap(formatter.date(from: "2022-01-02 12:00:00"))
Expand Down Expand Up @@ -112,6 +113,7 @@ class ValueConverterTest: XCTestCase {

func testValueConversion() throws {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let date = try XCTUnwrap(formatter.date(from: "2022-01-01 12:00:00"))

Expand Down
1 change: 1 addition & 0 deletions Tests/ConfidenceTests/ConfidenceIntegrationTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class ConfidenceIntegrationTests: XCTestCase {

private func convertStringToDate(_ dateString: String) -> Date? {
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
return dateFormatter.date(from: dateString)
}
Expand Down
3 changes: 3 additions & 0 deletions Tests/ConfidenceTests/ConfidenceValueTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final class ConfidenceConfidenceValueTests: XCTestCase {

func testStringShouldConvertToDate() throws {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let date = try XCTUnwrap(formatter.date(from: "2022-01-01 12:00:00"))
let value = ConfidenceValue(timestamp: date)
Expand All @@ -43,6 +44,7 @@ final class ConfidenceConfidenceValueTests: XCTestCase {

func testListShouldConvertToList() throws {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
formatter.timeZone = TimeZone(abbreviation: "UTC")
let date1 = try XCTUnwrap(formatter.date(from: "2022-01-01 12:00:00"))
Expand Down Expand Up @@ -106,6 +108,7 @@ final class ConfidenceConfidenceValueTests: XCTestCase {

func testEncodeDecode() throws {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
formatter.timeZone = TimeZone(abbreviation: "EDT") // Verify TimeZone conversion
let date = try XCTUnwrap(formatter.date(from: "2024-04-05 16:00:00"))
Expand Down
1 change: 1 addition & 0 deletions Tests/ConfidenceTests/TypeMapperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class TypeMapperTests: XCTestCase {

func testConfidenceToNetwork() throws {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
formatter.timeZone = TimeZone.init(identifier: "UTC+01")
let date = try XCTUnwrap(formatter.date(from: "2022-01-01 12:00:00"))
Expand Down

0 comments on commit 9cab6bb

Please sign in to comment.