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 18, 2023
1 parent 0c4b097 commit ecf503a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
4 changes: 1 addition & 3 deletions Sources/Forms/FormInputItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ open class FormInputItem: UIView, FormInputType {
textField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
}

required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
required public init?(coder: NSCoder) { nil }

private func setupViews() {
addSubview(stackView)
Expand Down
4 changes: 1 addition & 3 deletions Sources/Forms/FormSpacingItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@ open class FormSpacingItem: UIView, FormItem {
}
}

required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
required public init?(coder: NSCoder) { nil }
}
4 changes: 1 addition & 3 deletions Sources/Forms/FormTextItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ open class FormTextItem: UIView, FormItem {
setupAccessibility()
}

required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
required public init?(coder: NSCoder) { nil }

private func setupViews() {
addSubview(textLabel)
Expand Down
39 changes: 34 additions & 5 deletions Tests/FormsTests/FormInputItemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ final class FormInputItemTests: XCTestCase {
let placeholder = "Placeholder"
let initialText = "Initial Text"
let item = FormInputItem(
title: title,
initialText: initialText,
placeholder: placeholder,
spacingAfter: 20
configuration: .init(
title: title,
titleAttributes: [:],
initialText: initialText,
placeholder: placeholder,
isSecure: false,
autocorrectionType: .no,
autocapitalizationType: .none,
font: .boldSystemFont(ofSize: 10),
textColor: .blue,
cornerRadius: 10,
borderWidth: 2.0,
borderColor: .black,
spacingAfter: 20,
didChange: nil
)
)

XCTAssertEqual(
Expand All @@ -32,7 +44,24 @@ final class FormInputItemTests: XCTestCase {
}

func testConstraintsAreActive() {
let item = FormInputItem()
let item = FormInputItem(
configuration: .init(
title: nil,
titleAttributes: [:],
initialText: nil,
placeholder: nil,
isSecure: false,
autocorrectionType: .default,
autocapitalizationType: .allCharacters,
font: .boldSystemFont(ofSize: 1),
textColor: .black,
cornerRadius: 1,
borderWidth: 1,
borderColor: .black,
spacingAfter: 1,
didChange: nil
)
)
item.layoutIfNeeded() // Force layout so constraints are activated.

for constraint in item.constraints {
Expand Down
8 changes: 5 additions & 3 deletions Tests/FormsTests/FormTextItemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ final class FormTextItemTests: XCTestCase {
.foregroundColor: UIColor.red
]
let item = FormTextItem(
text: text,
attributes: attributes,
spacingAfter: spacing
configuration: .init(
text: text,
attributes: attributes,
spacingAfter: spacing
)
)
XCTAssertEqual(
item.spacingAfter, spacing,
Expand Down

0 comments on commit ecf503a

Please sign in to comment.