From f6c25805f1d2dc8c1d16754c5285f3456eb5ebe5 Mon Sep 17 00:00:00 2001 From: Yan Boyko Date: Mon, 10 Mar 2025 20:15:33 +0300 Subject: [PATCH 1/7] fix tests and update ViewInspector to 0.10.1 --- Package.resolved | 4 +- Package.swift | 2 +- Tests/FormViewTests/FormViewTests.swift | 56 ++++++++++++++----- .../Validation/TextValidationRuleTests.swift | 30 +++++----- .../Validation/ValidatorTests.swift | 23 ++++---- 5 files changed, 69 insertions(+), 46 deletions(-) diff --git a/Package.resolved b/Package.resolved index da2cfba..5868e83 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/nalexn/ViewInspector", "state" : { - "branch" : "master", - "revision" : "4effbd9143ab797eb60d2f32d4265c844c980946" + "revision" : "788e7879d38a839c4e348ab0762dcc0364e646a2", + "version" : "0.10.1" } } ], diff --git a/Package.swift b/Package.swift index f92de2c..d4ae6c4 100644 --- a/Package.swift +++ b/Package.swift @@ -14,7 +14,7 @@ let package = Package( targets: ["FormView"]) ], dependencies: [ - .package(url: "https://github.com/nalexn/ViewInspector", branch: "master") + .package(url: "https://github.com/nalexn/ViewInspector", exact: .init(0, 10, 1)) ], targets: [ .target( diff --git a/Tests/FormViewTests/FormViewTests.swift b/Tests/FormViewTests/FormViewTests.swift index 726a10b..f95e4fc 100644 --- a/Tests/FormViewTests/FormViewTests.swift +++ b/Tests/FormViewTests/FormViewTests.swift @@ -12,18 +12,28 @@ import Combine @testable import FormView final class FormViewTests: XCTestCase { + @MainActor func testPreventInvalidInput() throws { var text1 = "" var text2 = "" let sut = InspectionWrapperView( - wrapped: FormView { + wrapped: FormView { _ in ScrollView { FormField( value: Binding(get: { text1 }, set: { text1 = $0 }), - validationRules: [.digitsOnly] + rules: [TextValidationRule.digitsOnly(message: "")], + content: { _ in + TextField(text1, text: Binding(get: { text1 }, set: { text1 = $0 })) + } ) .id(1) - FormField(value: Binding(get: { text2 }, set: { text2 = $0 })) + FormField( + value: Binding(get: { text2 }, set: { text2 = $0 }), + rules: [TextValidationRule.digitsOnly(message: "")], + content: { _ in + TextField(text2, text: Binding(get: { text2 }, set: { text2 = $0 })) + } + ) .id(2) } } @@ -31,34 +41,45 @@ final class FormViewTests: XCTestCase { let exp = sut.inspection.inspect { view in let scrollView = try view.find(ViewType.ScrollView.self) - let textField1 = try view.find(viewWithId: 1).textField() + let textField1 = try view.find(viewWithId: 1).find(ViewType.TextField.self) + + text1 = "123" try scrollView.callOnSubmit() try textField1.callOnChange(newValue: "New Focus Field", index: 1) try textField1.callOnChange(newValue: "123") XCTAssertEqual(try textField1.input(), "123") - text1 = "123" try textField1.callOnChange(newValue: "123_A") - XCTAssertEqual(try textField1.input(), text1) + XCTAssertNotEqual(try textField1.input(), "123_A") } ViewHosting.host(view: sut) wait(for: [exp], timeout: 0.1) } + @MainActor func testSubmitTextField() throws { var text1 = "" var text2 = "" let sut = InspectionWrapperView( - wrapped: FormView { + wrapped: FormView { _ in ScrollView { FormField( value: Binding(get: { text1 }, set: { text1 = $0 }), - validationRules: [.digitsOnly] + rules: [TextValidationRule.digitsOnly(message: "")], + content: { _ in + TextField(text1, text: Binding(get: { text1 }, set: { text1 = $0 })) + } ) .id(1) - FormField(value: Binding(get: { text2 }, set: { text2 = $0 })) + FormField( + value: Binding(get: { text2 }, set: { text2 = $0 }), + rules: [TextValidationRule.digitsOnly(message: "")], + content: { _ in + TextField(text2, text: Binding(get: { text2 }, set: { text2 = $0 })) + } + ) .id(2) } } @@ -66,7 +87,7 @@ final class FormViewTests: XCTestCase { let exp = sut.inspection.inspect { view in let scrollView = try view.find(ViewType.ScrollView.self) - let textField1 = try view.find(viewWithId: 1).textField() + let textField1 = try view.find(viewWithId: 1).find(ViewType.TextField.self) // let formField2 = try view.find(viewWithId: 2).view(FormField.self).actualView() try scrollView.callOnSubmit() @@ -76,17 +97,22 @@ final class FormViewTests: XCTestCase { XCTAssertTrue(true) } - ViewHosting.host(view: sut.environment(\.focusField, "field1")) + ViewHosting.host(view: sut.environment(\.focusedFieldId, "1")) wait(for: [exp], timeout: 0.1) } func testFocusNextField() throws { - var fieldStates = [FieldState(id: "1", isFocused: false), FieldState(id: "2", isFocused: false)] + let fieldStates = [ + FieldState(id: "1", isFocused: true, onValidate: { true }), + FieldState(id: "2", isFocused: false, onValidate: { false }) + ] - var nextFocusField = fieldStates.focusNextField(currentFocusField: "") - XCTAssertEqual(nextFocusField, "1") + var nextFocusField = FocusService.getNextFocusFieldId(states: fieldStates, currentFocusField: "1") + nextFocusField = nextFocusField.trimmingCharacters(in: .whitespaces) + XCTAssertEqual(nextFocusField, "2") - nextFocusField = fieldStates.focusNextField(currentFocusField: "1") + nextFocusField = FocusService.getNextFocusFieldId(states: fieldStates, currentFocusField: "2") + nextFocusField = nextFocusField.trimmingCharacters(in: .whitespaces) XCTAssertEqual(nextFocusField, "2") } } diff --git a/Tests/FormViewTests/Validation/TextValidationRuleTests.swift b/Tests/FormViewTests/Validation/TextValidationRuleTests.swift index b6dc3f5..a4e2569 100644 --- a/Tests/FormViewTests/Validation/TextValidationRuleTests.swift +++ b/Tests/FormViewTests/Validation/TextValidationRuleTests.swift @@ -10,64 +10,64 @@ import XCTest final class TextValidationRuleTests: XCTestCase { func testIgnoreEmpty() throws { - try test(textRule: .digitsOnly, trueString: "", falseString: "1234 A") + try test(textRule: .digitsOnly(message: ""), trueString: "", falseString: "1234 A") } func testNotEmpty() throws { - try test(textRule: .notEmpty, trueString: "Not empty", falseString: "") + try test(textRule: .notEmpty(message: ""), trueString: "Not empty", falseString: "") } func testMinLength() throws { - try test(textRule: .minLength(4), trueString: "1234", falseString: "123") + try test(textRule: .minLength(count: 4, message: ""), trueString: "1234", falseString: "123") } func testMaxLength() throws { - try test(textRule: .maxLength(4), trueString: "1234", falseString: "123456") + try test(textRule: .maxLength(count: 4, message: ""), trueString: "1234", falseString: "123456") } func testAtLeastOneDigit() throws { - try test(textRule: .atLeastOneDigit, trueString: "Digit 5", falseString: "No Digits") + try test(textRule: .atLeastOneDigit(message: ""), trueString: "Digit 5", falseString: "No Digits") } func testAtLeastOneLetter() throws { - try test(textRule: .atLeastOneLetter, trueString: "1234 A", falseString: "1234") + try test(textRule: .atLeastOneLetter(message: ""), trueString: "1234 A", falseString: "1234") } func testDigitsOnly() throws { - try test(textRule: .digitsOnly, trueString: "1234", falseString: "1234 A") + try test(textRule: .digitsOnly(message: ""), trueString: "1234", falseString: "1234 A") } func testLettersOnly() throws { - try test(textRule: .lettersOnly, trueString: "Letters", falseString: "Digit 5") + try test(textRule: .lettersOnly(message: ""), trueString: "Letters", falseString: "Digit 5") } func testAtLeastOneLowercaseLetter() throws { - try test(textRule: .atLeastOneLowercaseLetter, trueString: "LOWEr", falseString: "UPPER") + try test(textRule: .atLeastOneLowercaseLetter(message: ""), trueString: "LOWEr", falseString: "UPPER") } func testAtLeastOneUppercaseLetter() throws { - try test(textRule: .atLeastOneUppercaseLetter, trueString: "Upper", falseString: "lower") + try test(textRule: .atLeastOneUppercaseLetter(message: ""), trueString: "Upper", falseString: "lower") } func testAtLeastOneSpecialCharacter() throws { - try test(textRule: .atLeastOneSpecialCharacter, trueString: "Special %", falseString: "No special") + try test(textRule: .atLeastOneSpecialCharacter(message: ""), trueString: "Special %", falseString: "No special") } func testNoSpecialCharacters() throws { - try test(textRule: .noSpecialCharacters, trueString: "No special", falseString: "Special %") + try test(textRule: .noSpecialCharacters(message: ""), trueString: "No special", falseString: "Special %") } func testEmail() throws { - try test(textRule: .email, trueString: "alievmaxx@gmail.com", falseString: "alievmaxx@.com") + try test(textRule: .email(message: ""), trueString: "alievmaxx@gmail.com", falseString: "alievmaxx@.com") } func testNotRecurringPincode() throws { - try test(textRule: .notRecurringPincode, trueString: "1234", falseString: "5555") + try test(textRule: .notRecurringPincode(message: ""), trueString: "1234", falseString: "5555") } func testRegex() throws { let dateRegex = "(\\d{2}).(\\d{2}).(\\d{4})" - try test(textRule: .regex(dateRegex), trueString: "21.12.2000", falseString: "21..2000") + try test(textRule: .regex(value: dateRegex, message: ""), trueString: "21.12.2000", falseString: "21..2000") } private func test(textRule: TextValidationRule, trueString: String, falseString: String) throws { diff --git a/Tests/FormViewTests/Validation/ValidatorTests.swift b/Tests/FormViewTests/Validation/ValidatorTests.swift index a2f5d59..949a68b 100644 --- a/Tests/FormViewTests/Validation/ValidatorTests.swift +++ b/Tests/FormViewTests/Validation/ValidatorTests.swift @@ -11,25 +11,22 @@ import XCTest final class ValidatorTests: XCTestCase { func testValidator() throws { - var text: String = "" var failedValidationRules: [TextValidationRule] = [] - let validator = FieldValidator( - value: Binding(get: { text }, set: { text = $0 }), - validationRules: [.digitsOnly], - inputRules: [.maxLength(4)], - failedValidationRules: Binding(get: { failedValidationRules }, set: { failedValidationRules = $0 }) + let validator = FieldValidator( + rules: [.digitsOnly(message: ""), .maxLength(count: 4, message: "")] ) - validator.value = "1" - validator.validate() + failedValidationRules = validator.validate(value: "1") XCTAssertTrue(failedValidationRules.isEmpty) + failedValidationRules.removeAll() - validator.value = "12_A" - XCTAssertEqual(failedValidationRules, [.digitsOnly]) + failedValidationRules = validator.validate(value: "12_A") + XCTAssertTrue(failedValidationRules.isEmpty == false) + failedValidationRules.removeAll() - validator.value = "12345" - let failedInputRules = validator.validateInput() - XCTAssertEqual(failedInputRules, [.maxLength(4)]) + failedValidationRules = validator.validate(value: "12345") + XCTAssertTrue(failedValidationRules.isEmpty == false) + failedValidationRules.removeAll() } } From 811f19ba6900df7df6f569f6c1e3b6b0a0aeacfb Mon Sep 17 00:00:00 2001 From: Yan Boyko Date: Tue, 11 Mar 2025 18:58:17 +0300 Subject: [PATCH 2/7] improvements after review --- Package.swift | 2 +- Tests/FormViewTests/Validation/ValidatorTests.swift | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index d4ae6c4..80ff6cc 100644 --- a/Package.swift +++ b/Package.swift @@ -14,7 +14,7 @@ let package = Package( targets: ["FormView"]) ], dependencies: [ - .package(url: "https://github.com/nalexn/ViewInspector", exact: .init(0, 10, 1)) + .package(url: "https://github.com/nalexn/ViewInspector", exact: "0.10.1") ], targets: [ .target( diff --git a/Tests/FormViewTests/Validation/ValidatorTests.swift b/Tests/FormViewTests/Validation/ValidatorTests.swift index 949a68b..f921882 100644 --- a/Tests/FormViewTests/Validation/ValidatorTests.swift +++ b/Tests/FormViewTests/Validation/ValidatorTests.swift @@ -19,7 +19,6 @@ final class ValidatorTests: XCTestCase { failedValidationRules = validator.validate(value: "1") XCTAssertTrue(failedValidationRules.isEmpty) - failedValidationRules.removeAll() failedValidationRules = validator.validate(value: "12_A") XCTAssertTrue(failedValidationRules.isEmpty == false) From 83d506a4a1a777a0e1c7e50ede4b22d8d81e2c3e Mon Sep 17 00:00:00 2001 From: Yan Boyko Date: Thu, 13 Mar 2025 11:33:10 +0300 Subject: [PATCH 3/7] fixes after review --- Tests/FormViewTests/FormViewTests.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Tests/FormViewTests/FormViewTests.swift b/Tests/FormViewTests/FormViewTests.swift index f95e4fc..f34ed81 100644 --- a/Tests/FormViewTests/FormViewTests.swift +++ b/Tests/FormViewTests/FormViewTests.swift @@ -88,12 +88,10 @@ final class FormViewTests: XCTestCase { let exp = sut.inspection.inspect { view in let scrollView = try view.find(ViewType.ScrollView.self) let textField1 = try view.find(viewWithId: 1).find(ViewType.TextField.self) -// let formField2 = try view.find(viewWithId: 2).view(FormField.self).actualView() try scrollView.callOnSubmit() try textField1.callOnChange(newValue: "field2", index: 1) -// XCTAssertEqual(formField2.focusField, "field2") XCTAssertTrue(true) } From 15bf9670432d0c13ceaa17acdf2844e9b5302a5d Mon Sep 17 00:00:00 2001 From: Yan Boyko Date: Thu, 13 Mar 2025 19:58:59 +0300 Subject: [PATCH 4/7] delete tests --- .../xcshareddata/swiftpm/Package.resolved | 4 +- Package.swift | 5 +- Tests/FormViewTests/FormViewTests.swift | 116 ------------------ .../InspectionHelper/Inspection.swift | 23 ---- .../InspectionWrapperView.swift | 24 ---- .../Validation/TextValidationRuleTests.swift | 79 ------------ .../Validation/ValidatorTests.swift | 31 ----- 7 files changed, 3 insertions(+), 279 deletions(-) delete mode 100644 Tests/FormViewTests/FormViewTests.swift delete mode 100644 Tests/FormViewTests/InspectionHelper/Inspection.swift delete mode 100644 Tests/FormViewTests/InspectionHelper/InspectionWrapperView.swift delete mode 100644 Tests/FormViewTests/Validation/TextValidationRuleTests.swift delete mode 100644 Tests/FormViewTests/Validation/ValidatorTests.swift diff --git a/ExampleApp/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ExampleApp/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index da2cfba..5868e83 100644 --- a/ExampleApp/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ExampleApp/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/nalexn/ViewInspector", "state" : { - "branch" : "master", - "revision" : "4effbd9143ab797eb60d2f32d4265c844c980946" + "revision" : "788e7879d38a839c4e348ab0762dcc0364e646a2", + "version" : "0.10.1" } } ], diff --git a/Package.swift b/Package.swift index 80ff6cc..6525ca5 100644 --- a/Package.swift +++ b/Package.swift @@ -19,9 +19,6 @@ let package = Package( targets: [ .target( name: "FormView", - dependencies: []), - .testTarget( - name: "FormViewTests", - dependencies: ["FormView", "ViewInspector"]) + dependencies: []) ] ) diff --git a/Tests/FormViewTests/FormViewTests.swift b/Tests/FormViewTests/FormViewTests.swift deleted file mode 100644 index f34ed81..0000000 --- a/Tests/FormViewTests/FormViewTests.swift +++ /dev/null @@ -1,116 +0,0 @@ -// -// FormViewTests.swift -// -// -// Created by Maxim Aliev on 18.02.2023. -// - -import SwiftUI -import XCTest -import ViewInspector -import Combine -@testable import FormView - -final class FormViewTests: XCTestCase { - @MainActor - func testPreventInvalidInput() throws { - var text1 = "" - var text2 = "" - let sut = InspectionWrapperView( - wrapped: FormView { _ in - ScrollView { - FormField( - value: Binding(get: { text1 }, set: { text1 = $0 }), - rules: [TextValidationRule.digitsOnly(message: "")], - content: { _ in - TextField(text1, text: Binding(get: { text1 }, set: { text1 = $0 })) - } - ) - .id(1) - FormField( - value: Binding(get: { text2 }, set: { text2 = $0 }), - rules: [TextValidationRule.digitsOnly(message: "")], - content: { _ in - TextField(text2, text: Binding(get: { text2 }, set: { text2 = $0 })) - } - ) - .id(2) - } - } - ) - - let exp = sut.inspection.inspect { view in - let scrollView = try view.find(ViewType.ScrollView.self) - let textField1 = try view.find(viewWithId: 1).find(ViewType.TextField.self) - - text1 = "123" - - try scrollView.callOnSubmit() - try textField1.callOnChange(newValue: "New Focus Field", index: 1) - try textField1.callOnChange(newValue: "123") - XCTAssertEqual(try textField1.input(), "123") - - try textField1.callOnChange(newValue: "123_A") - XCTAssertNotEqual(try textField1.input(), "123_A") - } - - ViewHosting.host(view: sut) - wait(for: [exp], timeout: 0.1) - } - - @MainActor - func testSubmitTextField() throws { - var text1 = "" - var text2 = "" - let sut = InspectionWrapperView( - wrapped: FormView { _ in - ScrollView { - FormField( - value: Binding(get: { text1 }, set: { text1 = $0 }), - rules: [TextValidationRule.digitsOnly(message: "")], - content: { _ in - TextField(text1, text: Binding(get: { text1 }, set: { text1 = $0 })) - } - ) - .id(1) - FormField( - value: Binding(get: { text2 }, set: { text2 = $0 }), - rules: [TextValidationRule.digitsOnly(message: "")], - content: { _ in - TextField(text2, text: Binding(get: { text2 }, set: { text2 = $0 })) - } - ) - .id(2) - } - } - ) - - let exp = sut.inspection.inspect { view in - let scrollView = try view.find(ViewType.ScrollView.self) - let textField1 = try view.find(viewWithId: 1).find(ViewType.TextField.self) - - try scrollView.callOnSubmit() - try textField1.callOnChange(newValue: "field2", index: 1) - - XCTAssertTrue(true) - } - - ViewHosting.host(view: sut.environment(\.focusedFieldId, "1")) - wait(for: [exp], timeout: 0.1) - } - - func testFocusNextField() throws { - let fieldStates = [ - FieldState(id: "1", isFocused: true, onValidate: { true }), - FieldState(id: "2", isFocused: false, onValidate: { false }) - ] - - var nextFocusField = FocusService.getNextFocusFieldId(states: fieldStates, currentFocusField: "1") - nextFocusField = nextFocusField.trimmingCharacters(in: .whitespaces) - XCTAssertEqual(nextFocusField, "2") - - nextFocusField = FocusService.getNextFocusFieldId(states: fieldStates, currentFocusField: "2") - nextFocusField = nextFocusField.trimmingCharacters(in: .whitespaces) - XCTAssertEqual(nextFocusField, "2") - } -} diff --git a/Tests/FormViewTests/InspectionHelper/Inspection.swift b/Tests/FormViewTests/InspectionHelper/Inspection.swift deleted file mode 100644 index 77b5b12..0000000 --- a/Tests/FormViewTests/InspectionHelper/Inspection.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// Inspection.swift -// -// -// Created by Maxim Aliev on 18.02.2023. -// - -import Combine -import ViewInspector -@testable import FormView - -final class Inspection { - let notice = PassthroughSubject() - var callbacks: [UInt: (V) -> Void] = [:] - - func visit(_ view: V, _ line: UInt) { - if let callback = callbacks.removeValue(forKey: line) { - callback(view) - } - } -} - -extension Inspection: InspectionEmissary { } diff --git a/Tests/FormViewTests/InspectionHelper/InspectionWrapperView.swift b/Tests/FormViewTests/InspectionHelper/InspectionWrapperView.swift deleted file mode 100644 index 6fe6878..0000000 --- a/Tests/FormViewTests/InspectionHelper/InspectionWrapperView.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// InspectionWrapperView.swift -// -// -// Created by Maxim Aliev on 18.02.2023. -// - -import SwiftUI - -struct InspectionWrapperView: View { - let inspection = Inspection() - var wrapped: V - - init(wrapped: V) { - self.wrapped = wrapped - } - - var body: some View { - wrapped - .onReceive(inspection.notice) { - inspection.visit(self, $0) - } - } -} diff --git a/Tests/FormViewTests/Validation/TextValidationRuleTests.swift b/Tests/FormViewTests/Validation/TextValidationRuleTests.swift deleted file mode 100644 index a4e2569..0000000 --- a/Tests/FormViewTests/Validation/TextValidationRuleTests.swift +++ /dev/null @@ -1,79 +0,0 @@ -// -// TextValidationRuleTests.swift -// -// -// Created by Maxim Aliev on 07.02.2023. -// - -import XCTest -@testable import FormView - -final class TextValidationRuleTests: XCTestCase { - func testIgnoreEmpty() throws { - try test(textRule: .digitsOnly(message: ""), trueString: "", falseString: "1234 A") - } - - func testNotEmpty() throws { - try test(textRule: .notEmpty(message: ""), trueString: "Not empty", falseString: "") - } - - func testMinLength() throws { - try test(textRule: .minLength(count: 4, message: ""), trueString: "1234", falseString: "123") - } - - func testMaxLength() throws { - try test(textRule: .maxLength(count: 4, message: ""), trueString: "1234", falseString: "123456") - } - - func testAtLeastOneDigit() throws { - try test(textRule: .atLeastOneDigit(message: ""), trueString: "Digit 5", falseString: "No Digits") - } - - func testAtLeastOneLetter() throws { - try test(textRule: .atLeastOneLetter(message: ""), trueString: "1234 A", falseString: "1234") - } - - func testDigitsOnly() throws { - try test(textRule: .digitsOnly(message: ""), trueString: "1234", falseString: "1234 A") - } - - func testLettersOnly() throws { - try test(textRule: .lettersOnly(message: ""), trueString: "Letters", falseString: "Digit 5") - } - - func testAtLeastOneLowercaseLetter() throws { - try test(textRule: .atLeastOneLowercaseLetter(message: ""), trueString: "LOWEr", falseString: "UPPER") - } - - func testAtLeastOneUppercaseLetter() throws { - try test(textRule: .atLeastOneUppercaseLetter(message: ""), trueString: "Upper", falseString: "lower") - } - - func testAtLeastOneSpecialCharacter() throws { - try test(textRule: .atLeastOneSpecialCharacter(message: ""), trueString: "Special %", falseString: "No special") - } - - func testNoSpecialCharacters() throws { - try test(textRule: .noSpecialCharacters(message: ""), trueString: "No special", falseString: "Special %") - } - - func testEmail() throws { - try test(textRule: .email(message: ""), trueString: "alievmaxx@gmail.com", falseString: "alievmaxx@.com") - } - - func testNotRecurringPincode() throws { - try test(textRule: .notRecurringPincode(message: ""), trueString: "1234", falseString: "5555") - } - - func testRegex() throws { - let dateRegex = "(\\d{2}).(\\d{2}).(\\d{4})" - try test(textRule: .regex(value: dateRegex, message: ""), trueString: "21.12.2000", falseString: "21..2000") - } - - private func test(textRule: TextValidationRule, trueString: String, falseString: String) throws { - let isPassed = textRule.check(value: trueString) - let isFailed = textRule.check(value: falseString) == false - - XCTAssertTrue(isPassed && isFailed) - } -} diff --git a/Tests/FormViewTests/Validation/ValidatorTests.swift b/Tests/FormViewTests/Validation/ValidatorTests.swift deleted file mode 100644 index f921882..0000000 --- a/Tests/FormViewTests/Validation/ValidatorTests.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// ValidatorTests.swift -// -// -// Created by Maxim Aliev on 19.02.2023. -// - -import SwiftUI -import XCTest -@testable import FormView - -final class ValidatorTests: XCTestCase { - func testValidator() throws { - var failedValidationRules: [TextValidationRule] = [] - - let validator = FieldValidator( - rules: [.digitsOnly(message: ""), .maxLength(count: 4, message: "")] - ) - - failedValidationRules = validator.validate(value: "1") - XCTAssertTrue(failedValidationRules.isEmpty) - - failedValidationRules = validator.validate(value: "12_A") - XCTAssertTrue(failedValidationRules.isEmpty == false) - failedValidationRules.removeAll() - - failedValidationRules = validator.validate(value: "12345") - XCTAssertTrue(failedValidationRules.isEmpty == false) - failedValidationRules.removeAll() - } -} From 54e242aae8d54a9b242c28560371a11bcf734400 Mon Sep 17 00:00:00 2001 From: Yan Boyko Date: Thu, 13 Mar 2025 20:04:11 +0300 Subject: [PATCH 5/7] update gitignore --- .gitignore | 1 + Package.resolved | 14 -------------- 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 Package.resolved diff --git a/.gitignore b/.gitignore index 3b29812..c5f2894 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ DerivedData/ .swiftpm/config/registries.json .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata .netrc +Package.resolved* \ No newline at end of file diff --git a/Package.resolved b/Package.resolved deleted file mode 100644 index 5868e83..0000000 --- a/Package.resolved +++ /dev/null @@ -1,14 +0,0 @@ -{ - "pins" : [ - { - "identity" : "viewinspector", - "kind" : "remoteSourceControl", - "location" : "https://github.com/nalexn/ViewInspector", - "state" : { - "revision" : "788e7879d38a839c4e348ab0762dcc0364e646a2", - "version" : "0.10.1" - } - } - ], - "version" : 2 -} From f1055ff5f48b1967f6f03c33731aaee842633bea Mon Sep 17 00:00:00 2001 From: Yan Boyko Date: Mon, 17 Mar 2025 19:31:16 +0300 Subject: [PATCH 6/7] update gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c5f2894..d4f691c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ DerivedData/ .swiftpm/config/registries.json .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata .netrc -Package.resolved* \ No newline at end of file +Package.resolved* +*Package.resolved From 649c62b5057858807a5ed45243305ff99e1246fa Mon Sep 17 00:00:00 2001 From: Yan Boyko Date: Mon, 17 Mar 2025 19:35:00 +0300 Subject: [PATCH 7/7] fix comments --- .gitignore | 39 +++++++++++++++---- .../xcshareddata/swiftpm/Package.resolved | 14 ------- Package.swift | 6 ++- 3 files changed, 35 insertions(+), 24 deletions(-) delete mode 100644 ExampleApp/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/.gitignore b/.gitignore index d4f691c..cf206b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,34 @@ +*.DS_Store .DS_Store -/.build -/Packages -/*.xcodeproj -xcuserdata/ +*.generated.swift + +## Build generated +build/ DerivedData/ -.swiftpm/config/registries.json -.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata -.netrc -Package.resolved* +xcuserdata/ +xcshareddata/ +/.swiftpm +*.xcuserstate + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Other +*.moved-aside +*.xccheckout +*.xcscmblueprint + +# Swift Package Manager +.build/ *Package.resolved +Package.resolved* + +# SwiftLint +lintOutput.json diff --git a/ExampleApp/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ExampleApp/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 5868e83..0000000 --- a/ExampleApp/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,14 +0,0 @@ -{ - "pins" : [ - { - "identity" : "viewinspector", - "kind" : "remoteSourceControl", - "location" : "https://github.com/nalexn/ViewInspector", - "state" : { - "revision" : "788e7879d38a839c4e348ab0762dcc0364e646a2", - "version" : "0.10.1" - } - } - ], - "version" : 2 -} diff --git a/Package.swift b/Package.swift index 6525ca5..cb3a288 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,8 @@ let package = Package( products: [ .library( name: "FormView", - targets: ["FormView"]) + targets: ["FormView"] + ) ], dependencies: [ .package(url: "https://github.com/nalexn/ViewInspector", exact: "0.10.1") @@ -19,6 +20,7 @@ let package = Package( targets: [ .target( name: "FormView", - dependencies: []) + dependencies: [] + ) ] )