Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Muniz Azevedo Filho committed Oct 25, 2023
1 parent 6846dc5 commit 6c22f20
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 43 deletions.
24 changes: 2 additions & 22 deletions Tests/FormsTests/FormCalendarItemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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(
Expand Down
5 changes: 2 additions & 3 deletions Tests/FormsTests/FormInputItemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
43 changes: 25 additions & 18 deletions Tests/FormsTests/FormTextItemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
Expand All @@ -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
)
Expand Down Expand Up @@ -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
))
}
}
2 changes: 2 additions & 0 deletions Tests/FormsTests/FormViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6c22f20

Please sign in to comment.