aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/form/tests
diff options
context:
space:
mode:
Diffstat (limited to 'includes/js/dojox/form/tests')
-rw-r--r--includes/js/dojox/form/tests/test_CheckedMultiSelect.html91
-rw-r--r--includes/js/dojox/form/tests/test_DropDownSelect.html128
-rw-r--r--includes/js/dojox/form/tests/test_PasswordValidator.html216
3 files changed, 435 insertions, 0 deletions
diff --git a/includes/js/dojox/form/tests/test_CheckedMultiSelect.html b/includes/js/dojox/form/tests/test_CheckedMultiSelect.html
new file mode 100644
index 0000000..b8729d2
--- /dev/null
+++ b/includes/js/dojox/form/tests/test_CheckedMultiSelect.html
@@ -0,0 +1,91 @@
+<html>
+ <head>
+ <script type="text/javascript"
+ src="../../../dojo/dojo.js"
+ djConfig="isDebug: true, parseOnLoad: true">
+ </script>
+ <script type="text/javascript">
+ dojo.require("doh.runner");
+ dojo.require("dojo.parser");
+ dojo.require("dojox.form.CheckedMultiSelect");
+ dojo.require("dijit.form.Button");
+ dojo.require("dijit.form.Form");
+
+ dojo.addOnLoad(function(){
+ doh.register("tests",
+ [
+ function test_setValue(t){
+ t.is(["VA","WA"], form.getValues().ms1);
+ form.setValues({ms1: ["TN","CA"]});
+ t.is(["TN","CA"], form.getValues().ms1);
+ ms1.invertSelection();
+ t.is(["VA","WA","FL"], form.getValues().ms1);
+ },
+ function test_addSelected(t){
+ ms1.addSelected(ms2);
+ t.is([], form.getValues().ms2);
+ ms1.invertSelection();
+ t.is(["TN","CA"], form.getValues().ms1);
+ },
+ ]
+ );
+ doh.run();
+ dojo.connect(ms1, "onChange", function(val){
+ console.log("First Select Changed to " + val);
+ });
+ });
+ </script>
+ <style>
+ @import url(../../../dojo/resources/dojo.css);
+ @import url(../../../dijit/themes/tundra/tundra.css);
+ @import url(../resources/CheckedMultiSelect.css);
+ @import url(../../../dijit/tests/css/dijitTests.css);
+ </style>
+ </head>
+ <body class="tundra">
+ <h1 class="testTitle">Test: dojox.form.CheckedMultiSelect</h1>
+ <h2>Automated test</h2>
+ <form dojoType="dijit.form.Form" jsId="form">
+ <select jsId="ms1" multiple="true" name="ms1" dojoType="dojox.form.CheckedMultiSelect">
+ <option value="TN">Tennessee</option>
+ <option value="VA" selected="selected">Virginia</option>
+ <option value="WA" selected="selected">Washington</option>
+ <option value="FL">Florida</option>
+ <option value="CA">California</option>
+ </select>
+ <hr>
+ <select jsId="ms2" multiple="true" name="ms2" dojoType="dojox.form.CheckedMultiSelect">
+ <option value="UT">Utah</option>
+ <option value="TX" selected="selected">Texas</option>
+ <option value="GA" selected="selected">Georgia</option>
+ <option value="ID">Idaho</option>
+ <option value="WY">Wyoming</option>
+ <option value="OR">Oregon</option>
+ <option value="PA">Pennsylvania</option>
+ </select>
+ <hr>
+ <select jsId="ms3" multiple="true" name="ms3" dojoType="dojox.form.CheckedMultiSelect">
+ </select>
+ <hr>
+ <button dojoType="dijit.form.Button">
+ <script type="dojo/method" event="onClick">
+ console.dir(form.getValues());
+ </script>
+ Get Values
+ </button>
+ <button dojoType="dijit.form.Button">
+ <script type="dojo/method" event="onClick">
+ var idx = dojo.query("option", ms3.domNode).length;
+ ms3.addOption(idx + "", "Option " + (idx + 1));
+ </script>
+ Add Option
+ </button>
+ <button dojoType="dijit.form.Button">
+ <script type="dojo/method" event="onClick">
+ ms3.setAttribute("disabled", !ms3.disabled);
+ </script>
+ Toggle Disabled
+ </button>
+ </form>
+ </body>
+</html>
diff --git a/includes/js/dojox/form/tests/test_DropDownSelect.html b/includes/js/dojox/form/tests/test_DropDownSelect.html
new file mode 100644
index 0000000..4487e54
--- /dev/null
+++ b/includes/js/dojox/form/tests/test_DropDownSelect.html
@@ -0,0 +1,128 @@
+<html>
+ <head>
+ <script type="text/javascript"
+ src="../../../dojo/dojo.js"
+ djConfig="isDebug: true, parseOnLoad: true">
+ </script>
+ <script type="text/javascript">
+ dojo.require("doh.runner");
+ dojo.require("dojo.parser");
+ dojo.require("dojox.form.DropDownSelect");
+ dojo.require("dijit.form.Button");
+ dojo.require("dijit.form.Form");
+
+ var numOptions = 0;
+ var numChanges = 0;
+
+ dojo.addOnLoad(function(){
+ dojo.connect(s1, "onChange", function(val){
+ console.log("First Select Changed to " + val);
+ numChanges++;
+ });
+ doh.register("tests",
+ [
+ function test_setValue(t){
+ t.is({s1:"VA", s2:"CA", s3:"AL", s4: "AK", s5: "move", s6:"", s7:"NY"}, form.getValues());
+ s1.setAttribute("value", "WA");
+ t.is("WA", s1.value);
+ s1.setAttribute("value", "UT");
+ t.is("TN", s1.value);
+ t.is(2, numChanges);
+ }
+ ]
+ );
+ doh.run();
+ });
+ </script>
+ <style>
+ @import url(../../../dojo/resources/dojo.css);
+ @import url(../../../dijit/themes/tundra/tundra.css);
+ @import url(../resources/DropDownSelect.css);
+ @import url(../../../dijit/tests/css/dijitTests.css);
+ </style>
+ <style>
+ .ark { text-decoration: underline; }
+ </style>
+ </head>
+ <body class="tundra">
+ <h1 class="testTitle">Test: dojox.form.DropDownSelect</h1>
+ <h2>Automated test</h2>
+ <form dojoType="dijit.form.Form" jsId="form">
+ <h4 class="testSubtitle">Setting Defaults</h4>
+ <select jsId="s1" name="s1" dojoType="dojox.form.DropDownSelect">
+ <option value="TN">Tennessee</option>
+ <option value="VA" selected="selected">Virginia</option>
+ <option value="WA">Washington</option>
+ <option value="FL">Florida</option>
+ <option value="CA">California</option>
+ </select>
+ <select jsId="s2" name="s2" value="CA" dojoType="dojox.form.DropDownSelect">
+ <option value="AL">Alabama</option>
+ <option value="AK">Alaska</option>
+ <option value="AZ">Arizona</option>
+ <option value="AR">Arkansas</option>
+ <option value="CA">California</option>
+ </select>
+ <select jsId="s3" name="s3" dojoType="dojox.form.DropDownSelect">
+ <option value="AL">Alabama</option>
+ <option value="AK">Alaska</option>
+ <option type="separator"></option>
+ <option value="AZ">Arizona</option>
+ <option value="AR">Arkansas</option>
+ <option type="separator"></option>
+ <option value="CA">California</option>
+ </select>
+ <hr>
+ <h4 class="testSubtitle">Rich Text (Need to use divs and spans - since browsers hack selects to pieces)</h4>
+ <div jsId="s4" name="s4" value="AK" dojoType="dojox.form.DropDownSelect">
+ <span value="AL"><b>Alabama</b></span>
+ <span value="AK"><font color="red">A</font><font color="orange">l</font><font color="yellow">a</font><font color="green">s</font><font color="blue">k</font><font color="purple">a</font></span>
+ <span value="AZ"><i>Arizona</i></span>
+ <span value="AR"><span class="ark">Arkansas</span></span>
+ <span value="CA"><span style="font-size:25%">C</span><span style="font-size:50%">a</span><span style="font-size:75%">l</span><span style="font-size:90%">i</span><span style="font-size:100%">f</span><span style="font-size:125%">o</span><span style="font-size:133%">r</span><span style="font-size:150%">n</span><span style="font-size:175%">i</span><span style="font-size:200%">a</span></span>
+ <span value="NM">New<br>&nbsp;&nbsp;Mexico</span>
+ </div>
+ <div jsId="s5" name="s5" value="move" dojoType="dojox.form.DropDownSelect">
+ <span value="copy"><img style="vertical-align: middle;margin-top: 1px;margin-bottom:1px;" src="../../../dijit/themes/tundra/images/dndCopy.png" /> Copy</span>
+ <span value="move"><img style="vertical-align: middle;margin-top: 1px;margin-bottom:1px;" src="../../../dijit/themes/tundra/images/dndMove.png" /> Move</span>
+ <span value="nocopy"><img style="vertical-align: middle;margin-top: 1px;margin-bottom:1px;" src="../../../dijit/themes/tundra/images/dndNoCopy.png" /> No Copy</span>
+ <span value="nomove"><img style="vertical-align: middle;margin-top: 1px;margin-bottom:1px;" src="../../../dijit/themes/tundra/images/dndNoMove.png" /> No Move</span>
+ </div>
+ <hr>
+ <h4 class="testSubtitle">Empty</h4>
+ <select jsId="s6" name="s6" dojoType="dojox.form.DropDownSelect">
+ </select>
+ <hr>
+ <h4 class="testSubtitle">Single Item</h4>
+ <select jsId="s7" name="s7" dojoType="dojox.form.DropDownSelect">
+ <option value="NY">New York</option>
+ </select>
+ <hr>
+ <button dojoType="dijit.form.Button">
+ <script type="dojo/method" event="onClick">
+ console.dir(form.getValues());
+ </script>
+ Get Values
+ </button>
+ <button dojoType="dijit.form.Button">
+ <script type="dojo/method" event="onClick">
+ numOptions++;
+ s6.addOption(numOptions + "", "Option " + numOptions);
+ </script>
+ Add Option
+ </button>
+ <button dojoType="dijit.form.Button">
+ <script type="dojo/method" event="onClick">
+ s6.removeOption(0);
+ </script>
+ Remove Top Option
+ </button>
+ <button dojoType="dijit.form.Button">
+ <script type="dojo/method" event="onClick">
+ s4.setAttribute("disabled", !s4.disabled);
+ </script>
+ Toggle Disabled
+ </button>
+ </form>
+ </body>
+</html>
diff --git a/includes/js/dojox/form/tests/test_PasswordValidator.html b/includes/js/dojox/form/tests/test_PasswordValidator.html
new file mode 100644
index 0000000..e3b1e63
--- /dev/null
+++ b/includes/js/dojox/form/tests/test_PasswordValidator.html
@@ -0,0 +1,216 @@
+<html>
+ <head>
+ <script type="text/javascript"
+ src="../../../dojo/dojo.js"
+ djConfig="isDebug: true, parseOnLoad: true">
+ </script>
+ <script type="text/javascript">
+ dojo.require("doh.runner");
+ dojo.require("dojo.parser");
+ dojo.require("dojox.form.PasswordValidator");
+ dojo.require("dijit.form.Button");
+ dojo.require("dijit.form.Form");
+
+ dojo.addOnLoad(function(){
+ doh.register("tests",
+ [
+ function test_setDisabled(t){
+ valid1.setAttribute("disabled", true);
+ t.t(dojo.every(dojo.query("[widgetId]",
+ valid1.domNode).map(function(i){
+ return dijit.byNode(i);
+ }), function(i){return i.disabled;}));
+ valid1.setAttribute("disabled", false);
+ t.t(dojo.every(dojo.query("[widgetId]",
+ valid1.domNode).map(function(i){
+ return dijit.byNode(i);
+ }), function(i){return !i.disabled;}));
+ },
+ function test_isValid(t){
+ t.f(form1.isValid());
+ dijit.byId("nv1").setValue("test");
+ dijit.byId("vv1").setValue("Test");
+ t.f(form1.isValid());
+ dijit.byId("vv1").setValue("test");
+ t.t(form1.isValid());
+ t.t(form6.isValid());
+ t.is({password: ""}, form6.getValues());
+ dijit.byId("nv6").setValue("test");
+ t.f(form6.isValid());
+ t.is({password: ""}, form6.getValues());
+ dijit.byId("vv6").setValue("test");
+ t.t(form6.isValid());
+ t.is({password: "test"}, form6.getValues());
+ },
+ function test_getValue(t){
+ dijit.byId("nv1").setValue("test");
+ dijit.byId("vv1").setValue("Test");
+ t.is({password: ""}, form1.getValues());
+ dijit.byId("vv1").setValue("test123");
+ dijit.byId("nv1").setValue("test123");
+ t.is({password: "test123"}, form1.getValues());
+ },
+ function test_oldPW(t){
+ dijit.byId("nv2").setValue("test");
+ dijit.byId("vv2").setValue("test");
+ t.f(form2.isValid());
+ dijit.byId("ov2").setValue("oldpw4");
+ t.f(form2.isValid());
+ dijit.byId("ov2").setValue("oldpw2");
+ t.t(form2.isValid());
+ },
+ function test_getOldValue(t){
+ t.is({password: "test"}, form2.getValues());
+ dijit.byId("nv3").setValue("test");
+ dijit.byId("vv3").setValue("test");
+ dijit.byId("ov3").setValue("oldpw4");
+ t.is({password: "", oldPassword: ""}, form3.getValues());
+ dijit.byId("ov3").setValue("oldpw3");
+ dijit.byId("vv3").setValue("Test");
+ t.is({password: "", oldPassword: ""}, form3.getValues());
+ dijit.byId("vv3").setValue("test");
+ t.is({password: "test", oldPassword: "oldpw3"}, form3.getValues());
+ },
+ function test_getValuesInTable(t){
+ dijit.byId("nv4").setValue("test");
+ dijit.byId("vv4").setValue("test");
+ dijit.byId("ov4").setValue("oldpw4");
+ t.is({password: "test"}, form4.getValues());
+ dijit.byId("nv5").setValue("test");
+ dijit.byId("vv5").setValue("test");
+ dijit.byId("ov5").setValue("oldpw5");
+ t.is({password: "test", oldPassword: "oldpw5"}, form5.getValues());
+ }
+ ]
+ );
+ doh.run();
+ });
+ </script>
+ <link rel="stylesheet" type="text/css" href="../../../dijit/themes/tundra/tundra.css">
+ <link rel="stylesheet" type="text/css" href="../../../dijit/tests/css/dijitTests.css">
+ </head>
+ <body class="tundra">
+ <h1 class="testTitle">Test: dojox.form.PasswordValidator</h1>
+ <h2>Automated test</h2>
+ <h4 class="testSubtitle">No old password</h4>
+ <form dojoType="dijit.form.Form" jsId="form1">
+ <div dojoType="dojox.form.PasswordValidator" jsId="valid1" name="password">
+ <label>Password: <input type="password" id="nv1" pwType="new" /></label><br>
+ <label>Validate: <input type="password" id="vv1" pwType="verify" /></label><br>
+ </div>
+ </form>
+ <hr>
+ <h4 class="testSubtitle">Old password (hard-coded to "oldpw2") - not passed to getValues</h4>
+ <form dojoType="dijit.form.Form" jsId="form2">
+ <div dojoType="dojox.form.PasswordValidator" jsId="valid2" name="password">
+ <script type="dojo/method" event="pwCheck" args="password">
+ /*
+ NOTE: Do NOT EVER EVER EVER do this sort of a check!!!
+
+ This is only as an example. You will probably want to
+ override the pwCheck function to callback to a server to
+ verify the password (the callback will need to be
+ syncronous) - and it's probably a good idea to validate
+ it again on form submission before actually doing
+ anything destructive - that's why the "oldName" value
+ is there.
+
+ And don't just fetch the password from the server
+ either :) Send the test password (probably hashed, for
+ security) and return from the server a status instead.
+
+ Again - DON'T DO THIS - it is HORRIBLY INSECURE!!!!
+
+ Security is left as an exercise to the reader :)
+ */
+ return password === "oldpw2";
+ </script>
+ <label>Old Password: <input type="password" id="ov2" pwType="old" /></label><br>
+ <label>Password: <input type="password" id="nv2" pwType="new" /></label><br>
+ <label>Validate: <input type="password" id="vv2" pwType="verify" /></label><br>
+ </div>
+ </form>
+ <hr>
+ <h4 class="testSubtitle">Old password (hard-coded to "oldpw3") - passed to getValues</h4>
+ <form dojoType="dijit.form.Form" jsId="form3">
+ <div dojoType="dojox.form.PasswordValidator" jsId="valid3" name="password" oldName="oldPassword">
+ <script type="dojo/method" event="pwCheck" args="password">
+ console.log("Checking " + password);
+ return password === "oldpw3";
+ </script>
+ <label>Old Password: <input type="password" id="ov3" pwType="old" /></label><br>
+ <label>Password: <input type="password" id="nv3" pwType="new" /></label><br>
+ <label>Validate: <input type="password" id="vv3" pwType="verify" /></label><br>
+ </div>
+ </form>
+ <hr>
+ <h4 class="testSubtitle">In Table, Old password (hard-coded to "oldpw4") - not passed to getValues</h4>
+ <form dojoType="dijit.form.Form" jsId="form4">
+ <div dojoType="dojox.form.PasswordValidator" jsId="valid4" name="password">
+ <script type="dojo/method" event="pwCheck" args="password">
+ return password === "oldpw4";
+ </script>
+ <table>
+ <tr>
+ <td><label for="ov4">Old Password:</label></td>
+ <td><input type="password" id="ov4" pwType="old" /></td>
+ </tr>
+ <tr>
+ <td><label for="nv4">Password:</label></td>
+ <td><input type="password" id="nv4" pwType="new" /></td>
+ </tr>
+ <tr>
+ <td><label for="vv4">Validate:</label></td>
+ <td><input type="password" id="vv4" pwType="verify" /></td>
+ </tr>
+ </table>
+ </div>
+ </form>
+ <hr>
+ <h4 class="testSubtitle">In Table, Old password (hard-coded to "oldpw5") - passed to getValues</h4>
+ <form dojoType="dijit.form.Form" jsId="form5">
+ <div dojoType="dojox.form.PasswordValidator" jsId="valid5" name="password" oldName="oldPassword">
+ <script type="dojo/method" event="pwCheck" args="password">
+ return password === "oldpw5";
+ </script>
+ <table>
+ <tr>
+ <td><label for="ov5">Old Password:</label></td>
+ <td><input type="password" id="ov5" pwType="old" /></td>
+ </tr>
+ <tr>
+ <td><label for="nv5">Password:</label></td>
+ <td><input type="password" id="nv5" pwType="new" /></td>
+ </tr>
+ <tr>
+ <td><label for="vv5">Validate:</label></td>
+ <td><input type="password" id="vv5" pwType="verify" /></td>
+ </tr>
+ </table>
+ </div>
+ </form>
+ <hr>
+ <h4 class="testSubtitle">No old password, not required</h4>
+ <form dojoType="dijit.form.Form" jsId="form6">
+ <div dojoType="dojox.form.PasswordValidator" required="false" jsId="valid6" name="password">
+ <label>Password: <input type="password" id="nv6" pwType="new" /></label><br>
+ <label>Validate: <input type="password" id="vv6" pwType="verify" /></label><br>
+ </div>
+ </form>
+ <hr>
+ <button dojoType="dijit.form.Button">
+ <script type="dojo/method" event="onClick">
+ dojo.forEach([form1, form2, form3, form4, form5, form6], function(i){
+ console.dir(i.getValues());
+ });
+ </script>
+ Get Values
+ </button>
+ <button dojoType="dijit.form.Button">
+ <script type="dojo/method" event="onClick">
+ valid5.setAttribute("disabled", !valid5.disabled);
+ </script>
+ Toggle Disabled
+ </button>
+ </body>
+</html>