Merge pull request #93 from jpotts18/increasing-coverage
Adding tests to check error messages. Somewhat trivial but it tests t…
This commit is contained in:
commit
a35e66a4a9
|
|
@ -68,6 +68,10 @@ class SwiftValidatorTests: XCTestCase {
|
|||
XCTAssertFalse(RequiredRule().validate(""), "Required should be invalid")
|
||||
}
|
||||
|
||||
func testRequiredMessage() {
|
||||
XCTAssertNotNil(RequiredRule().errorMessage())
|
||||
}
|
||||
|
||||
// MARK: Regex
|
||||
|
||||
func testRegex(){
|
||||
|
|
@ -78,6 +82,10 @@ class SwiftValidatorTests: XCTestCase {
|
|||
XCTAssertFalse(RegexRule(regex: USERNAME_REGEX).validate("DarthVader"), "RegexRule should be invalid")
|
||||
}
|
||||
|
||||
func testRegexMessage() {
|
||||
XCTAssertNotNil(RegexRule(regex: USERNAME_REGEX).errorMessage())
|
||||
}
|
||||
|
||||
// MARK: Zipcode
|
||||
|
||||
func testZipCode() {
|
||||
|
|
@ -88,6 +96,10 @@ class SwiftValidatorTests: XCTestCase {
|
|||
XCTAssertFalse(ZipCodeRule().validate(INVALID_ZIP), "Zipcode should be invalid")
|
||||
}
|
||||
|
||||
func testZipCodeMessage() {
|
||||
XCTAssertNotNil(ZipCodeRule().errorMessage())
|
||||
}
|
||||
|
||||
// MARK: Email
|
||||
|
||||
func testEmail() {
|
||||
|
|
@ -98,6 +110,10 @@ class SwiftValidatorTests: XCTestCase {
|
|||
XCTAssertFalse(EmailRule().validate(INVALID_EMAIL), "Email should be invalid")
|
||||
}
|
||||
|
||||
func testEmailMessage() {
|
||||
XCTAssertNotNil(EmailRule().errorMessage())
|
||||
}
|
||||
|
||||
// MARK: Float
|
||||
|
||||
func testFloat() {
|
||||
|
|
@ -109,6 +125,10 @@ class SwiftValidatorTests: XCTestCase {
|
|||
XCTAssert(!FloatRule().validate(VALID_EMAIL), "Float should be invalid")
|
||||
}
|
||||
|
||||
func testFloatMessage() {
|
||||
XCTAssertNotNil(FloatRule().errorMessage())
|
||||
}
|
||||
|
||||
// MARK: Confirm against field
|
||||
|
||||
func testConfirmSame(){
|
||||
|
|
@ -121,6 +141,11 @@ class SwiftValidatorTests: XCTestCase {
|
|||
XCTAssertFalse(ConfirmationRule(confirmField: CONFIRM_TXT_FIELD).validate(CONFIRM_TEXT_DIFF), "Should fail confirm")
|
||||
}
|
||||
|
||||
func testConfirmMessage() {
|
||||
CONFIRM_TXT_FIELD.text = CONFIRM_TEXT
|
||||
XCTAssertNotNil(ConfirmationRule(confirmField: CONFIRM_TXT_FIELD).errorMessage())
|
||||
}
|
||||
|
||||
// MARK: Password
|
||||
|
||||
func testPassword() {
|
||||
|
|
@ -128,7 +153,11 @@ class SwiftValidatorTests: XCTestCase {
|
|||
}
|
||||
|
||||
func testPasswordInvalid(){
|
||||
XCTAssertFalse(EmailRule().validate(INVALID_PASSWORD), "Password is invalid")
|
||||
XCTAssertFalse(PasswordRule().validate(INVALID_PASSWORD), "Password is invalid")
|
||||
}
|
||||
|
||||
func testPasswordMessage() {
|
||||
XCTAssertNotNil(PasswordRule().errorMessage())
|
||||
}
|
||||
|
||||
func testPhoneNumber() {
|
||||
|
|
@ -139,6 +168,10 @@ class SwiftValidatorTests: XCTestCase {
|
|||
XCTAssertFalse(PhoneNumberRule().validate("12345678901"), "Phone number should be invalid")
|
||||
}
|
||||
|
||||
func testPhoneNumberMessage() {
|
||||
XCTAssertNotNil(PhoneNumberRule().errorMessage())
|
||||
}
|
||||
|
||||
// MARK: Max Length
|
||||
|
||||
func testMaxLength(){
|
||||
|
|
@ -153,6 +186,10 @@ class SwiftValidatorTests: XCTestCase {
|
|||
XCTAssertTrue(MaxLengthRule(length: 20).validate(LEN_20), "Max Length should be 20 and <= length")
|
||||
}
|
||||
|
||||
func testMaxLengthMessage() {
|
||||
XCTAssertNotNil(MaxLengthRule(length: 20).errorMessage())
|
||||
}
|
||||
|
||||
// MARK: Min Length
|
||||
func testMinLength(){
|
||||
XCTAssertTrue(MinLengthRule().validate(LEN_3),"Min Length should be valid")
|
||||
|
|
@ -166,6 +203,10 @@ class SwiftValidatorTests: XCTestCase {
|
|||
XCTAssertTrue(MinLengthRule(length: 5).validate(LEN_5), "Min Len should be set to 5 and >= length")
|
||||
}
|
||||
|
||||
func testMinLengthMessage() {
|
||||
XCTAssertNotNil(MinLengthRule(length: 5).errorMessage())
|
||||
}
|
||||
|
||||
func testExactLength(){
|
||||
XCTAssertTrue(ExactLengthRule(length: 5).validate(LEN_5), "Exact Len should be exactly 5")
|
||||
}
|
||||
|
|
@ -178,6 +219,10 @@ class SwiftValidatorTests: XCTestCase {
|
|||
XCTAssertFalse(ExactLengthRule(length: 4).validate(LEN_5), "Exact Len should be Invalid")
|
||||
}
|
||||
|
||||
func testExactLengthMessage() {
|
||||
XCTAssertNotNil(ExactLengthRule(length: 4).errorMessage())
|
||||
}
|
||||
|
||||
// MARK: Full Name
|
||||
|
||||
func testFullName(){
|
||||
|
|
|
|||
Loading…
Reference in New Issue