Skip to content

Commit

Permalink
Refactor unit tests for the UI module
Browse files Browse the repository at this point in the history
  • Loading branch information
ns-vasilev committed Dec 24, 2024
1 parent 97e59cd commit 5b96cb5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
1 change: 1 addition & 0 deletions Sources/ValidatorUI/Classes/IUIValidatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ValidatorCore

// MARK: - IUIValidatable

@MainActor
public protocol IUIValidatable: AnyObject {
associatedtype Input

Expand Down
22 changes: 6 additions & 16 deletions Tests/ValidatorUITests/UnitTests/UITextFieldTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,13 @@ import XCTest

#if os(iOS)
final class UITextFieldTests: XCTestCase {
// MARK: Properties

private var textField: UITextField!

// MARK: XCTestCase

override func setUp() {
super.setUp()
textField = UITextField()
}

override func tearDown() {
textField = nil
super.tearDown()
}

// MARK: Tests

@MainActor
func test_thatTextFieldValidationReturnsValid_whenInputValueIsValid() {
// given
let textField = UITextField()

textField.validateOnInputChange(isEnabled: true)
textField.add(rule: LengthValidationRule(max: .max, error: String.error))

Expand All @@ -49,8 +36,11 @@ import XCTest
else { XCTFail("The result must be equal to the valid value") }
}

@MainActor
func test_thatTextFieldValidationReturnsInvalid_whenInputValueIsInvalid() {
// given
let textField = UITextField()

textField.validateOnInputChange(isEnabled: true)
textField.add(rule: LengthValidationRule(max: .max, error: String.error))

Expand Down

0 comments on commit 5b96cb5

Please sign in to comment.