You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2012/03/05 07:03:00 UTC
svn commit: r1296939 -
/incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as
Author: jmclean
Date: Mon Mar 5 06:03:00 2012
New Revision: 1296939
URL: http://svn.apache.org/viewvc?rev=1296939&view=rev
Log:
added test for multiple validators
Modified:
incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as
Modified: incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as?rev=1296939&r1=1296938&r2=1296939&view=diff
==============================================================================
--- incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as (original)
+++ incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as Mon Mar 5 06:03:00 2012
@@ -13,10 +13,6 @@ package tests
public function setUp():void
{
validator = new PostCodeValidator();
-
- // Currently stored in a static variables as the the doValidation method is static
- validator.format = null;
- validator.countryCode = null;
}
[After]
@@ -63,15 +59,15 @@ package tests
return false;
}
- private function invalidFormatError(results:Array) {
+ private function invalidFormatError(results:Array):void {
assertTrue("Has format error", hasError(results, "wrongFormat"));
}
- private function wrongLengthError(results:Array) {
+ private function wrongLengthError(results:Array):void {
assertTrue("Has wrong length error", hasError(results, "wrongLength"));
}
- private function invalidCharError(results:Array) {
+ private function invalidCharError(results:Array):void {
assertTrue("Has invalid character error", hasError(results, "invalidChar"));
}
@@ -266,12 +262,14 @@ package tests
invalidFormatError(results);
results = PostCodeValidator.validatePostCode(validator, "12345 AB", null);
- assertTrue("Invalid Postcode", results.length == 1);
+ assertTrue("Invalid Postcode", results.length == 2);
wrongLengthError(results);
+ invalidFormatError(results);
results = PostCodeValidator.validatePostCode(validator, "123 AB", null);
- assertTrue("Invalid Postcode", results.length == 1);
+ assertTrue("Invalid Postcode", results.length == 2);
wrongLengthError(results);
+ invalidFormatError(results);
}
[Test]
@@ -327,5 +325,21 @@ package tests
}
}
+ [Test]
+ public function multipleFormats():void {
+ var validator1:PostCodeValidator = new PostCodeValidator();
+ var validator2:PostCodeValidator = new PostCodeValidator();
+ var results:Array = [];
+
+ validator1.format = "AAAA";
+ validator2.format = "NNNNNN";
+
+ results = PostCodeValidator.validatePostCode(validator1, "ABCD", null);
+ assertTrue("Valid Postcode", results.length == 0);
+ results = PostCodeValidator.validatePostCode(validator2, "123456", null);
+ assertTrue("Valid Postcode", results.length == 0);
+
+ }
+
}
}
\ No newline at end of file