Skip to content

Commit cc3c7c1

Browse files
committed
Solve Github comments
1 parent bfa527a commit cc3c7c1

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

AdyenCardScannerTests/CardImageParserTests.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@ import XCTest
1111
final class CardImageParserTests: XCTestCase {
1212

1313
var sut: CardImageParser!
14+
var expirationDateFormatter: ExpirationDateFormatter!
15+
16+
override func setUpWithError() throws {
17+
try super.setUpWithError()
18+
expirationDateFormatter = ExpirationDateFormatter()
19+
}
1420

1521
override func tearDownWithError() throws {
1622
sut = nil
23+
expirationDateFormatter = nil
1724
try super.tearDownWithError()
1825
}
1926

@@ -35,7 +42,7 @@ final class CardImageParserTests: XCTestCase {
3542
}
3643

3744
// Then
38-
waitForExpectations(timeout: 10.0)
45+
wait(for: [expectation], timeout: 0.1)
3946
}
4047

4148
func testParseImageWithLowContrastCardImage() throws {
@@ -56,7 +63,7 @@ final class CardImageParserTests: XCTestCase {
5663
}
5764

5865
// Then
59-
waitForExpectations(timeout: 10.0)
66+
wait(for: [expectation], timeout: 0.1)
6067
}
6168

6269
func testParseImageWithInvalidLuhnCheck() throws {
@@ -78,7 +85,7 @@ final class CardImageParserTests: XCTestCase {
7885
}
7986

8087
// Then
81-
waitForExpectations(timeout: 10.0)
88+
wait(for: [expectation], timeout: 0.1)
8289
}
8390

8491
// MARK: - Private
@@ -145,9 +152,7 @@ final class CardImageParserTests: XCTestCase {
145152
)
146153
}
147154

148-
149155
private func dateFrom(_ string: String) -> Date? {
150-
let dateFormatter = ExpirationDateFormatter()
151-
return dateFormatter.date(from: string)
156+
return expirationDateFormatter.date(from: string)
152157
}
153158
}

AdyenCardScannerTests/ExpirationDateFormatterTests.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@ import XCTest
1010
final class ExpirationDateFormatterTests: XCTestCase {
1111

1212
var sut: ExpirationDateFormatter!
13-
var dateFormatter: DateFormatter!
13+
var dateFormatter = DateFormatter()
1414

1515
override func setUpWithError() throws {
1616
try super.setUpWithError()
17-
dateFormatter = DateFormatter()
1817
dateFormatter.dateFormat = "MM/yyyy"
1918
dateFormatter.locale = Locale.current
2019
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
2120
}
2221

2322
override func tearDownWithError() throws {
2423
sut = nil
25-
dateFormatter = nil
2624
try super.tearDownWithError()
2725
}
2826

0 commit comments

Comments
 (0)