diff options
Diffstat (limited to 'framework/Web/Javascripts/tests/ValidationTests.html')
-rw-r--r-- | framework/Web/Javascripts/tests/ValidationTests.html | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/framework/Web/Javascripts/tests/ValidationTests.html b/framework/Web/Javascripts/tests/ValidationTests.html new file mode 100644 index 00000000..67c9aecb --- /dev/null +++ b/framework/Web/Javascripts/tests/ValidationTests.html @@ -0,0 +1,79 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Prado Client-Side Validation Tests</title>
+ <link rel="stylesheet" type="text/css" href="jsunit/css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="jsunit/app/jsUnitCore.js"></script>
+<!-- unit tests -->
+<!-- base files -->
+<script language="JavaScript" Type="text/javascript" src="../../base.js"></script>
+<script language="JavaScript" Type="text/javascript" src="../../dom.js"></script>
+<!-- library file -->
+<script language="JavaScript" Type="text/javascript" src="../library/validation/validator.js"></script>
+<script language="JavaScript" type="text/javascript">
+
+ function testConvertInteger()
+ {
+ var convert = Prado.Validation.Util;
+
+ //test integers
+ assertEquals("Integer 10", 10, convert.toInteger("10"));
+ assertNull("Not an integer", convert.toInteger("10.0"));
+ assertEquals("+ integer", 10, convert.toInteger(" +10 "));
+ }
+
+ function testConvertDouble()
+ {
+ var convert = Prado.Validation.Util;
+
+ //test doubles
+ assertEquals("Double 10.0", 10.0, convert.toDouble("10.0","."));
+ assertNull("Not a double", convert.toDouble("10.0s"));
+ assertEquals("+ double", 10.2, convert.toDouble(" +10.2 "));
+ }
+
+ function testConvertAsCurrency()
+ {
+ var convert = Prado.Validation.Util;
+
+ //test currency convert
+ assertEquals("10 Dollars", 10, convert.toCurrency("10.00"));
+ assertEquals("10,000 Dollars", 10000.10, convert.toCurrency("10,000.10"));
+
+ //using space as grouping
+ assertEquals("10 000 Dollars", 10000.10, convert.toCurrency("10 000.10", " "));
+
+ assertEquals("1 0000 Yen", 10000, convert.toCurrency("1 0000", " ",0));
+
+ assertNull("Not 10 Dollars", convert.toCurrency("$10.0"));
+ }
+
+ function testConvertToDate()
+ {
+ var convert = Prado.Validation.Util;
+
+ //test dates !! Months are zero based for javascript Date objects !!
+ var testDate = (new Date(2005, 05, 20)).valueOf();
+ assertEquals("Matching date 2005 May 20", testDate, convert.toDate("2005-06-20", "%Y-%m-%d"));
+ }
+
+ function testValidatorConversion()
+ {
+ var validator = new Prado.Validation(null, {id : "", controltovalidate : "", groupchar: " ", digits : 0});
+ assertEquals("Integer 10", 10, validator.convert("Integer", "10"));
+ assertEquals("10 000 Yen", 10000, validator.convert("Currency", "10 000"));
+ }
+</script>
+ </head>
+
+ <body>
+ <h1>Prado Client-Side Validation Tests</h1>
+
+ <p>This page contains tests for the utility functions
+ that JsUnit uses. To see them, take a look at the source.</p>
+ </body>
+</html>
+
|