From 6c22f202b64ebfa733941c559c7f946316f891d0 Mon Sep 17 00:00:00 2001 From: Bruno Muniz Azevedo Filho Date: Tue, 24 Oct 2023 22:44:18 -0300 Subject: [PATCH] Fix unit tests --- Tests/FormsTests/FormCalendarItemTests.swift | 24 +---------- Tests/FormsTests/FormInputItemTests.swift | 5 +-- Tests/FormsTests/FormTextItemTests.swift | 43 ++++++++++++-------- Tests/FormsTests/FormViewTests.swift | 2 + 4 files changed, 31 insertions(+), 43 deletions(-) diff --git a/Tests/FormsTests/FormCalendarItemTests.swift b/Tests/FormsTests/FormCalendarItemTests.swift index 67e2849..8063956 100644 --- a/Tests/FormsTests/FormCalendarItemTests.swift +++ b/Tests/FormsTests/FormCalendarItemTests.swift @@ -5,15 +5,14 @@ import XCTest final class FormCalendarItemTests: XCTestCase { func testProperInitialization() { let configuration = FormCalendarItem.Configuration( - title: "mock_title", + title: [NSAttributedString(string: "mock_title")], calendar: .init(identifier: .chinese), tintColor: .red, spacingAfter: 12, availableRange: .none, delegate: nil, selectionMultiDate: nil, - selectionSingleDate: nil, - titleAttributes: [:] + selectionSingleDate: nil ) let calendarItem = FormCalendarItem(configuration: configuration) @@ -41,25 +40,6 @@ final class FormCalendarItemTests: XCTestCase { func testSelectionSingleDateDelegate() { let singleDelegate = MockSelectionSingleDateDelegate() - let calendarItem = FormCalendarItem(configuration: .init( - title: "", - calendar: .current, - tintColor: .blue, - spacingAfter: 0, - availableRange: nil, - delegate: nil, - selectionMultiDate: nil, - selectionSingleDate: .init( - delegate: singleDelegate, - selectedDate: DateComponents( - year: 2023, - month: 10, - day: 19 - ) - ), - titleAttributes: [:] - )) - singleDelegate.dateSelection( UICalendarSelectionSingleDate(delegate: nil), didSelectDate: DateComponents( diff --git a/Tests/FormsTests/FormInputItemTests.swift b/Tests/FormsTests/FormInputItemTests.swift index 47b4432..9b96b1a 100644 --- a/Tests/FormsTests/FormInputItemTests.swift +++ b/Tests/FormsTests/FormInputItemTests.swift @@ -8,10 +8,9 @@ final class FormInputItemTests: XCTestCase { let initialText = "Initial Text" let item = FormInputItem( configuration: .init( - title: title, - titleAttributes: [:], + title: [NSAttributedString(string: title)], initialText: initialText, - placeholder: placeholder, + placeholder: [NSAttributedString(string: placeholder)], isSecure: false, autocorrectionType: .no, autocapitalizationType: .none, diff --git a/Tests/FormsTests/FormTextItemTests.swift b/Tests/FormsTests/FormTextItemTests.swift index c24c076..594b198 100644 --- a/Tests/FormsTests/FormTextItemTests.swift +++ b/Tests/FormsTests/FormTextItemTests.swift @@ -10,9 +10,12 @@ final class FormTextItemTests: XCTestCase { .foregroundColor: UIColor.red ] let item = FormTextItem( - configuration: .init( - text: text, - attributes: attributes, + configuration: FormTextItem.Configuration( + text: [ + NSAttributedString( + string: text, + attributes: attributes + )], spacingAfter: spacing ) ) @@ -32,11 +35,14 @@ final class FormTextItemTests: XCTestCase { let font = UIFont.systemFont(ofSize: 16) let spacing: CGFloat = 15 let item = FormTextItem( - configuration: .init( - text: text, - attributes: [ - .foregroundColor: color, - .font: font + configuration: FormTextItem.Configuration( + text: [ + NSAttributedString( + string: text, + attributes: [ + .font: font, + .foregroundColor: color + ]) ], spacingAfter: spacing ) @@ -127,15 +133,16 @@ private extension FormTextItem { _ string: String, _ spacingAfter: CGFloat = 10 ) -> FormTextItem { - FormTextItem( - configuration: .init( - text: string, - attributes: [ - .foregroundColor: UIColor.black, - .font: UIFont.systemFont(ofSize: 12) - ], - spacingAfter: spacingAfter - ) - ) + FormTextItem(configuration: .init( + text: [ + NSAttributedString( + string: string, + attributes: [ + .foregroundColor: UIColor.black, + .font: UIFont.systemFont(ofSize: 12) + ]) + ], + spacingAfter: spacingAfter + )) } } diff --git a/Tests/FormsTests/FormViewTests.swift b/Tests/FormsTests/FormViewTests.swift index a133a77..44f5c29 100644 --- a/Tests/FormsTests/FormViewTests.swift +++ b/Tests/FormsTests/FormViewTests.swift @@ -109,6 +109,8 @@ final class FormViewTests: XCTestCase { } private final class FormItemMock: UIView, FormItem, Validatable { + var value: String { fatalError() } + var spacingAfter: CGFloat var isValid: Bool