| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 | <title>DOH MVC Date Binding Test</title> |
| 6 | <style type="text/css"> |
| 7 | @import "../../../../dojo/resources/dojo.css"; |
| 8 | @import "../../../../dijit/themes/claro/claro.css"; |
| 9 | </style> |
| 10 | <script type="text/javascript" data-dojo-config="parseOnLoad:0,isDebug:1,async:1,mvc:{debugBindings:1}" src="../../../../dojo/dojo.js"></script> |
| 11 | <script type="text/javascript"> |
| 12 | require([ |
| 13 | "doh/runner", |
| 14 | "dojo/dom", |
| 15 | "dojo/dom-style", |
| 16 | "dojo/parser", |
| 17 | "dojo/Stateful", |
| 18 | "dojo/date/stamp", |
| 19 | "dojo/date/locale", |
| 20 | "dojox/mvc/at", |
| 21 | "dijit/registry", |
| 22 | "dijit/CalendarLite", |
| 23 | "dijit/form/Button", |
| 24 | "dijit/form/DateTextBox", |
| 25 | "dijit/form/TextBox", |
| 26 | "dojox/mvc/EditModelRefController", |
| 27 | "dojox/mvc/Output", |
| 28 | "dojo/domReady!" |
| 29 | ], function(doh, ddom, domStyle, parser, Stateful, dateStamp, dateLocale, at, registry, Calendar, Button, DateTextBox, TextBox, EditModelRefController, Output){ |
| 30 | |
| 31 | parser.parse(); |
| 32 | |
| 33 | var dummyDateWid = new DateTextBox({constraints:{datePattern:"MM-dd-yyyy h:mm a", strict:true}}); |
| 34 | |
| 35 | // *** Test1 setup begin: *** |
| 36 | test1_ctrl = new EditModelRefController({sourceModel: new Stateful({date: new Date(1987, 7, 1, 1, 0, 0, 0)})}); // Sets the time to 1am, see dijit._CalendarList._patchDate() |
| 37 | |
| 38 | var test1_cal = new Calendar({value: at(test1_ctrl, "date")}, ddom.byId("test1_cal")); |
| 39 | test1_cal.startup(); |
| 40 | |
| 41 | var test1_cal2 = new Calendar({value: at(test1_ctrl, "date")}, ddom.byId("test1_cal2")); |
| 42 | test1_cal2.startup(); |
| 43 | |
| 44 | var test1_txt2 = new TextBox({value: at(test1_ctrl, "date").transform(dummyDateWid.dateLocaleModule), constraints: dummyDateWid.constraints}, ddom.byId("test1_txt2")); |
| 45 | domStyle.set(test1_txt2.domNode, "width", "368px"); |
| 46 | test1_txt2.startup(); |
| 47 | |
| 48 | var test1_out2 = new Output({value: at(test1_ctrl, "date").transform(dummyDateWid.dateLocaleModule), |
| 49 | constraints: dummyDateWid.constraints}, ddom.byId("test1_output2")); |
| 50 | test1_out2.startup(); |
| 51 | |
| 52 | var test1_setday2 = new Button({ |
| 53 | label: "Set Calendar to Sep 7 1989", |
| 54 | onClick: function() { |
| 55 | var day2 = new Date(1989, 8, 7, 1, 0, 0, 0); // Sets the time to 1am, see dijit._CalendarList._patchDate() |
| 56 | test1_cal2.set("value", day2); |
| 57 | } |
| 58 | }, ddom.byId("test1_setdate1")); |
| 59 | test1_setday2.startup(); |
| 60 | |
| 61 | var test1_settext2 = new Button({ |
| 62 | label: "Set TextBox to May 5, 1991", |
| 63 | onClick: function() { |
| 64 | test1_txt2.set("value", dateLocale.format(new Date(1991, 4, 5, 1, 0, 0, 0), {datePattern: "MM-dd-yyyy h:mm a", selector: "date"})); // Sets the time to 1am, see dijit._CalendarList._patchDate() |
| 65 | } |
| 66 | }, ddom.byId("test1_setdate2")); |
| 67 | test1_settext2.startup(); |
| 68 | |
| 69 | var test1_settext3 = new Button({ |
| 70 | label: "Set TextBox to Nov 6, 2011", |
| 71 | onClick: function() { |
| 72 | test1_txt2.set("value", dateLocale.format(new Date(2011, 10, 7, 1, 0, 0, 0), {datePattern: "MM-dd-yyyy h:mm a", selector: "date"})); |
| 73 | } |
| 74 | }, ddom.byId("test1_setdate3")); |
| 75 | test1_settext3.startup(); |
| 76 | |
| 77 | var test1_reset2 = new Button({ |
| 78 | label: "Reset Calendar back to Aug 1 1987", |
| 79 | onClick: function() { |
| 80 | test1_ctrl.reset(); |
| 81 | } |
| 82 | }, ddom.byId("test1_reset2")); |
| 83 | test1_reset2.startup(); |
| 84 | // *** Test1 setup end: *** |
| 85 | |
| 86 | // *** Test2 setup begin: *** |
| 87 | test2_ctrl = new EditModelRefController({sourceModel: new Stateful({date: new Date(2011, 10, 6, 1, 0, 0, 0)})}); // Sets the time to 1am, see dijit._CalendarList._patchDate() |
| 88 | var test2_cal = new DateTextBox({value: at(test2_ctrl, "date")}, ddom.byId("test2_cal")); |
| 89 | test2_cal.startup(); |
| 90 | |
| 91 | var test2_cal2 = new DateTextBox({value: at(test2_ctrl, "date")}, ddom.byId("test2_cal2")); |
| 92 | test2_cal2.startup(); |
| 93 | |
| 94 | var test2_txt2 = new TextBox({value: at(test2_ctrl, "date").transform(dummyDateWid.dateLocaleModule), constraints: dummyDateWid.constraints}, ddom.byId("test2_txt2")); |
| 95 | domStyle.set(test2_txt2.domNode, "width", "368px"); |
| 96 | test2_txt2.startup(); |
| 97 | |
| 98 | var test2_out2 = new Output({value: at(test2_ctrl, "date").transform(dummyDateWid.dateLocaleModule), |
| 99 | constraints: dummyDateWid.constraints}, ddom.byId("test2_output2")); |
| 100 | test2_out2.startup(); |
| 101 | |
| 102 | var test2_setday2 = new Button({ |
| 103 | label: "Set DateTextBox to Oct 28, 1993", |
| 104 | onClick: function() { |
| 105 | var day2 = dateLocale.format(new Date(1993, 9, 28, 1, 0, 0, 0), {datePattern: "MM-dd-yyyy h:mm a", selector: "date"}); // Sets the time to 1am, see dijit._CalendarList._patchDate() |
| 106 | test2_txt2.set("value", day2); |
| 107 | } |
| 108 | }, ddom.byId("test2_setdate1")); |
| 109 | test2_setday2.startup(); |
| 110 | |
| 111 | var test2_settext2 = new Button({ |
| 112 | label: "Set DateTextBox to Oct 14 1997", |
| 113 | onClick: function() { |
| 114 | test2_txt2.set("value", dateLocale.format(new Date(1997, 9, 14, 1, 0, 0, 0), {datePattern: "MM-dd-yyyy h:mm a", selector: "date"})); |
| 115 | } |
| 116 | }, ddom.byId("test2_setdate2")); |
| 117 | test2_settext2.startup(); |
| 118 | |
| 119 | var test2_reset2 = new Button({ |
| 120 | label: "Reset DateTextBox back to Nov 6 2011", |
| 121 | onClick: function() { |
| 122 | test2_ctrl.reset(); |
| 123 | } |
| 124 | }, ddom.byId("test2_reset2")); |
| 125 | |
| 126 | var test2_settext3 = new Button({ |
| 127 | label: "Set TextBox to May 5, 1991", |
| 128 | onClick: function() { |
| 129 | test2_txt2.set("value", dateLocale.format(new Date(1991, 4, 5, 1, 0, 0, 0), {datePattern: "MM-dd-yyyy h:mm a", selector: "date"})); |
| 130 | } |
| 131 | }, ddom.byId("test2_setdate3")); |
| 132 | test2_settext3.startup(); |
| 133 | |
| 134 | test2_reset2.startup(); |
| 135 | // *** Test2 setup end: *** |
| 136 | |
| 137 | // *** Test3 setup begin: *** |
| 138 | var test3_init = new Date(2011, 7, 27, 1, 0, 0, 0); // Sets the time to 1am, see dijit._CalendarList._patchDate() |
| 139 | test3_ctrl = new EditModelRefController({sourceModel: new Stateful({date: test3_init})}); |
| 140 | |
| 141 | var test3_cal = new Calendar({value: at(test3_ctrl, "date")}, ddom.byId("test3_cal")); |
| 142 | test3_cal.startup(); |
| 143 | |
| 144 | var test3_cal2 = new DateTextBox({value: at(test3_ctrl, "date")}, ddom.byId("test3_cal2")); |
| 145 | test3_cal2.startup(); |
| 146 | |
| 147 | var test3_txt2 = new TextBox({ |
| 148 | value: at(test3_ctrl, "date").transform(dummyDateWid.dateLocaleModule), |
| 149 | constraints: dummyDateWid.constraints, |
| 150 | disabled: true |
| 151 | }, ddom.byId("test3_txt2")); |
| 152 | domStyle.set(test3_txt2.domNode, "width", "368px"); |
| 153 | test3_txt2.startup(); |
| 154 | |
| 155 | var test3_out2 = new Output({value: at(test3_ctrl, "date").transform(dummyDateWid.dateLocaleModule), |
| 156 | constraints: dummyDateWid.constraints}, ddom.byId("test3_output2")); |
| 157 | test3_out2.startup(); |
| 158 | |
| 159 | var test3_setday2 = new Button({ |
| 160 | label: "Set Calendar to Oct 14 1997", |
| 161 | onClick: function() { |
| 162 | var day2 = new Date(1997, 9, 14, 1, 0, 0, 0); // Sets the time to 1am, see dijit._CalendarList._patchDate() |
| 163 | test3_cal2.set("value", day2); |
| 164 | } |
| 165 | }, ddom.byId("test3_setdate1")); |
| 166 | test3_setday2.startup(); |
| 167 | |
| 168 | var test3_settext2 = new Button({ |
| 169 | label: "Set TextBox to Nov 6, 2011", |
| 170 | onClick: function() { |
| 171 | test3_txt2.set("value", dateLocale.format(new Date(2011, 10, 6, 1, 0, 0, 0), {datePattern: "MM-dd-yyyy h:mm a", selector: "date"})); // Sets the time to 1am, see dijit._CalendarList._patchDate() |
| 172 | } |
| 173 | }, ddom.byId("test3_setdate2")); |
| 174 | test3_settext2.startup(); |
| 175 | |
| 176 | var test3_settext3 = new Button({ |
| 177 | label: "Set TextBox to May 5, 1991", |
| 178 | onClick: function() { |
| 179 | var d = dateLocale.format(new Date(1991, 4, 5, 1, 0, 0, 0), {datePattern: "MM-dd-yyyy h:mm a", selector: "date"}); // Sets the time to 1am, see dijit._CalendarList._patchDate() |
| 180 | test3_txt2.set("value", d); // 5/5/1991 YYYY-MM-DDThh:mm:ss via new Date |
| 181 | } |
| 182 | }, ddom.byId("test3_setdate3")); |
| 183 | test3_settext3.startup(); |
| 184 | |
| 185 | var test3_reset2 = new Button({ |
| 186 | label: "Reset Calendar back to Aug 27 2011", |
| 187 | onClick: function() { |
| 188 | test3_ctrl.reset(); |
| 189 | } |
| 190 | }, ddom.byId("test3_reset2")); |
| 191 | test3_reset2.startup(); |
| 192 | // *** Test3 setup end: *** |
| 193 | |
| 194 | // *** Test4 setup begin: RegExp Test*** |
| 195 | test4_ctrl = new EditModelRefController({sourceModel: new Stateful({regex: /abc/i})}); |
| 196 | // *** Test4 setup end: *** |
| 197 | |
| 198 | // *** Test5 setup begin: Falsy Test*** |
| 199 | test5_model = new Stateful({ |
| 200 | u: void 0, |
| 201 | z: 0, |
| 202 | n: null, |
| 203 | f: false, |
| 204 | s: "" |
| 205 | }); |
| 206 | // *** Test5 setup end: *** |
| 207 | |
| 208 | doh.register("Check initial values and bindings", [{ |
| 209 | name: "Initial-test1", |
| 210 | runTest: function(){ |
| 211 | doh.is("1987", registry.byId("test1_cal").get("value").getFullYear(),"test1_cal getFullYear should be 1987"); |
| 212 | doh.is("7", registry.byId("test1_cal").get("value").getMonth(),"test1_cal getMonth should be 7"); |
| 213 | doh.is("1", registry.byId("test1_cal").get("value").getDate(),"test1_cal getDate should be 1"); |
| 214 | doh.is("1987", registry.byId("test1_cal2").get("value").getFullYear(),"test1_cal2 getFullYear should be 1987"); |
| 215 | doh.is("7", registry.byId("test1_cal2").get("value").getMonth(),"test1_cal2 getMonth should be 7"); |
| 216 | doh.is("1", registry.byId("test1_cal2").get("value").getDate(),"test1_cal2 getDate should be 1"); |
| 217 | doh.is("08-01-1987 1:00 AM", registry.byId("test1_txt2").get("value"), "test1_txt2 should be 08-01-1987 1:00 AM"); |
| 218 | doh.is("08-01-1987 1:00 AM", registry.byId("test1_output2").get("value"), "test1_output2 should be 08-01-1987 1:00 AM"); |
| 219 | } |
| 220 | }, { |
| 221 | name: "Initial-test2", |
| 222 | runTest: function(){ |
| 223 | doh.is("2011", registry.byId("test2_cal").get("value").getFullYear(),"test2_cal getFullYear should be 1987"); |
| 224 | doh.is("10", registry.byId("test2_cal").get("value").getMonth(),"test2_cal getMonth should be 10"); |
| 225 | doh.is("6", registry.byId("test2_cal").get("value").getDate(),"test2_cal getDate should be 6"); |
| 226 | doh.is("2011", registry.byId("test2_cal2").get("value").getFullYear(),"test2_cal2 getFullYear should be 1987"); |
| 227 | doh.is("10", registry.byId("test2_cal2").get("value").getMonth(),"test2_cal2 getMonth should be 10"); |
| 228 | doh.is("6", registry.byId("test2_cal2").get("value").getDate(),"test2_cal2 getDate should be 6"); |
| 229 | doh.is("11-06-2011 1:00 AM", registry.byId("test2_txt2").get("value"), "test2_txt2 should be 11-06-2011 1:00 AM"); |
| 230 | doh.is("11-06-2011 1:00 AM", registry.byId("test2_output2").get("value"), "test2_output2 should be 11-06-2011 1:00 AM"); |
| 231 | } |
| 232 | }, { |
| 233 | name: "Initial-test3", |
| 234 | runTest: function(){ |
| 235 | doh.is("2011", registry.byId("test3_cal").get("value").getFullYear(),"test3_cal getFullYear should be 1987"); |
| 236 | doh.is("7", registry.byId("test3_cal").get("value").getMonth(),"test3_cal getMonth should be 7"); |
| 237 | doh.is("27", registry.byId("test3_cal").get("value").getDate(),"test3_cal getDate should be 27"); |
| 238 | doh.is("2011", registry.byId("test3_cal2").get("value").getFullYear(),"test3_cal2 getFullYear should be 1987"); |
| 239 | doh.is("7", registry.byId("test3_cal2").get("value").getMonth(),"test3_cal2 getMonth should be 7"); |
| 240 | doh.is("27", registry.byId("test3_cal2").get("value").getDate(),"test3_cal2 getDate should be 27"); |
| 241 | doh.is("08-27-2011 1:00 AM", registry.byId("test3_txt2").get("value"), "test3_txt2 should be 08-27-2011 1:00 AM"); |
| 242 | doh.is("08-27-2011 1:00 AM", registry.byId("test3_output2").get("value"), "test3_output2 should be 08-27-2011 1:00 AM"); |
| 243 | } |
| 244 | }]); |
| 245 | |
| 246 | doh.register("Update first cal", [{ |
| 247 | name: "Update-First-Cal-test1", |
| 248 | runTest: function(){ |
| 249 | var day2 = new Date(1989, 8, 7, 1, 0, 0, 0); // 9/7/1989 (Sets the time to 1am, see dijit._CalendarList._patchDate()) |
| 250 | registry.byId(test1_cal).set("value", day2); |
| 251 | doh.is("1989", registry.byId("test1_cal").get("value").getFullYear(),"test1_cal getFullYear should be 1989"); |
| 252 | doh.is("8", registry.byId("test1_cal").get("value").getMonth(),"test1_cal getMonth should be 8"); |
| 253 | doh.is("7", registry.byId("test1_cal").get("value").getDate(),"test1_cal getDate should be 7"); |
| 254 | doh.is("1989", registry.byId("test1_cal2").get("value").getFullYear(),"test1_cal2 getFullYear should be 1989"); |
| 255 | doh.is("8", registry.byId("test1_cal2").get("value").getMonth(),"test1_cal2 getMonth should be 8"); |
| 256 | doh.is("7", registry.byId("test1_cal2").get("value").getDate(),"test1_cal2 getDate should be 7"); |
| 257 | doh.is("09-07-1989 1:00 AM", registry.byId("test1_txt2").get("value"), "test1_txt2 should be 09-07-1989 1:00 AM"); |
| 258 | doh.is("09-07-1989 1:00 AM", registry.byId("test1_output2").get("value"), "test1_output2 should be 09-07-1989 1:00 AM"); |
| 259 | } |
| 260 | }, { |
| 261 | name: "Update-First-Cal-test2", |
| 262 | runTest: function(){ |
| 263 | var day2 = new Date(1989, 8, 7, 1, 0, 0, 0); // 9/7/1989 (Sets the time to 1am, see dijit._CalendarList._patchDate()) |
| 264 | registry.byId(test2_cal).set("value", day2); |
| 265 | doh.is("1989", registry.byId("test2_cal").get("value").getFullYear(),"test2_cal getFullYear should be 1989"); |
| 266 | doh.is("8", registry.byId("test2_cal").get("value").getMonth(),"test2_cal getMonth should be 8"); |
| 267 | doh.is("7", registry.byId("test2_cal").get("value").getDate(),"test2_cal getDate should be 7"); |
| 268 | doh.is("1989", registry.byId("test2_cal2").get("value").getFullYear(),"test2_cal2 getFullYear should be 1989"); |
| 269 | doh.is("8", registry.byId("test2_cal2").get("value").getMonth(),"test2_cal2 getMonth should be 8"); |
| 270 | doh.is("7", registry.byId("test2_cal2").get("value").getDate(),"test2_cal2 getDate should be 7"); |
| 271 | doh.is("09-07-1989 1:00 AM", registry.byId("test2_txt2").get("value"), "test2_txt2 should be 09-07-1989 1:00 AM"); |
| 272 | doh.is("09-07-1989 1:00 AM", registry.byId("test2_output2").get("value"), "test2_output2 should be 09-07-1989 1:00 AM"); |
| 273 | } |
| 274 | }, { |
| 275 | name: "Update-First-Cal-test3", |
| 276 | runTest: function(){ |
| 277 | var day2 = new Date(1989, 8, 7, 1, 0, 0, 0); // 9/7/1989 (Sets the time to 1am, see dijit._CalendarList._patchDate()) |
| 278 | registry.byId(test3_cal).set("value", day2); |
| 279 | doh.is("1989", registry.byId("test3_cal").get("value").getFullYear(),"test3_cal getFullYear should be 1989"); |
| 280 | doh.is("8", registry.byId("test3_cal").get("value").getMonth(),"test3_cal getMonth should be 8"); |
| 281 | doh.is("7", registry.byId("test3_cal").get("value").getDate(),"test3_cal getDate should be 7"); |
| 282 | doh.is("1989", registry.byId("test3_cal2").get("value").getFullYear(),"test3_cal2 getFullYear should be 1989"); |
| 283 | doh.is("8", registry.byId("test3_cal2").get("value").getMonth(),"test3_cal2 getMonth should be 8"); |
| 284 | doh.is("7", registry.byId("test3_cal2").get("value").getDate(),"test3_cal2 getDate should be 7"); |
| 285 | doh.is("09-07-1989 1:00 AM", registry.byId("test3_txt2").get("value"), "test3_txt2 should be 09-07-1989 1:00 AM"); |
| 286 | doh.is("09-07-1989 1:00 AM", registry.byId("test3_output2").get("value"), "test3_output2 should be 09-07-1989 1:00 AM"); |
| 287 | } |
| 288 | }]); |
| 289 | |
| 290 | doh.register("Update textbox", [{ |
| 291 | name: "Update-TextBox-test1", |
| 292 | runTest: function(){ |
| 293 | registry.byId(test1_txt2).set("value", "05-05-1991 1:00 AM"); |
| 294 | doh.is("1991", registry.byId("test1_cal").get("value").getFullYear(),"test1_cal getFullYear should be 1991"); |
| 295 | doh.is("4", registry.byId("test1_cal").get("value").getMonth(),"test1_cal getMonth should be 4"); |
| 296 | doh.is("5", registry.byId("test1_cal").get("value").getDate(),"test1_cal getDate should be 4"); |
| 297 | doh.is("1991", registry.byId("test1_cal2").get("value").getFullYear(),"test1_cal2 getFullYear should be 1991"); |
| 298 | doh.is("4", registry.byId("test1_cal2").get("value").getMonth(),"test1_cal2 getMonth should be 4"); |
| 299 | doh.is("5", registry.byId("test1_cal2").get("value").getDate(),"test1_cal2 getDate should be 5"); |
| 300 | doh.is("05-05-1991 1:00 AM", registry.byId("test1_txt2").get("value"), "test1_txt2 should be 05-05-1991 1:00 AM"); |
| 301 | doh.is("05-05-1991 1:00 AM", registry.byId("test1_output2").get("value"), "test1_output2 should be 05-05-1991 1:00 AM"); |
| 302 | } |
| 303 | }, { |
| 304 | name: "Update-TextBox-test2", |
| 305 | runTest: function(){ |
| 306 | registry.byId(test2_txt2).set("value", "05-05-1991 1:00 AM"); |
| 307 | doh.is("1991", registry.byId("test2_cal").get("value").getFullYear(),"test2_cal getFullYear should be 1991"); |
| 308 | doh.is("4", registry.byId("test2_cal").get("value").getMonth(),"test2_cal getMonth should be 4"); |
| 309 | doh.is("5", registry.byId("test2_cal").get("value").getDate(),"test2_cal getDate should be 4"); |
| 310 | doh.is("1991", registry.byId("test2_cal2").get("value").getFullYear(),"test2_cal2 getFullYear should be 1991"); |
| 311 | doh.is("4", registry.byId("test2_cal2").get("value").getMonth(),"test2_cal2 getMonth should be 4"); |
| 312 | doh.is("5", registry.byId("test2_cal2").get("value").getDate(),"test2_cal2 getDate should be 5"); |
| 313 | doh.is("05-05-1991 1:00 AM", registry.byId("test2_txt2").get("value"), "test2_txt2 should be 05-05-1991 1:00 AM"); |
| 314 | doh.is("05-05-1991 1:00 AM", registry.byId("test2_output2").get("value"), "test2_output2 should be 05-05-1991 1:00 AM"); |
| 315 | } |
| 316 | }, { |
| 317 | name: "Update-TextBox-test3", |
| 318 | runTest: function(){ |
| 319 | registry.byId(test3_txt2).set("value", "05-05-1991 1:00 AM"); |
| 320 | doh.is("1991", registry.byId("test3_cal").get("value").getFullYear(),"test3_cal getFullYear should be 1991"); |
| 321 | doh.is("4", registry.byId("test3_cal").get("value").getMonth(),"test3_cal getMonth should be 4"); |
| 322 | doh.is("5", registry.byId("test3_cal").get("value").getDate(),"test3_cal getDate should be 4"); |
| 323 | doh.is("1991", registry.byId("test3_cal2").get("value").getFullYear(),"test3_cal2 getFullYear should be 1991"); |
| 324 | doh.is("4", registry.byId("test3_cal2").get("value").getMonth(),"test3_cal2 getMonth should be 4"); |
| 325 | doh.is("5", registry.byId("test3_cal2").get("value").getDate(),"test3_cal2 getDate should be 5"); |
| 326 | doh.is("05-05-1991 1:00 AM", registry.byId("test3_txt2").get("value"), "test3_txt2 should be 05-05-1991 1:00 AM"); |
| 327 | doh.is("05-05-1991 1:00 AM", registry.byId("test3_output2").get("value"), "test3_output2 should be 05-05-1991 1:00 AM"); |
| 328 | } |
| 329 | }]); |
| 330 | |
| 331 | doh.register("Update cal with new date", [{ |
| 332 | name: "Update-withNewDate-test1", |
| 333 | runTest: function(){ |
| 334 | var day2 = new Date(1993, 9, 28, 1, 0, 0, 0); // 10/28/1993 |
| 335 | var test = day2.toDateString(); |
| 336 | var startTime3 = (new Date()).getTime(); |
| 337 | registry.byId(test1_cal).set("value", day2); |
| 338 | doh.is("1993", registry.byId("test1_cal").get("value").getFullYear(),"test1_cal getFullYear should be 1993"); |
| 339 | doh.is("9", registry.byId("test1_cal").get("value").getMonth(),"test1_cal getMonth should be 9"); |
| 340 | doh.is("28", registry.byId("test1_cal").get("value").getDate(),"test1_cal getDate should be 28"); |
| 341 | doh.is("1993", registry.byId("test1_cal2").get("value").getFullYear(),"test1_cal2 getFullYear should be 1993"); |
| 342 | doh.is("9", registry.byId("test1_cal2").get("value").getMonth(),"test1_cal2 getMonth should be 9"); |
| 343 | doh.is("28", registry.byId("test1_cal2").get("value").getDate(),"test1_cal2 getDate should be 28"); |
| 344 | doh.is("10-28-1993 1:00 AM", registry.byId("test1_txt2").get("value"), "test1_txt2 should be 10-28-1993 1:00 AM"); |
| 345 | doh.is("10-28-1993 1:00 AM", registry.byId("test1_output2").get("value"), "test1_output2 should be 10-28-1993 1:00 AM"); |
| 346 | } |
| 347 | }, { |
| 348 | name: "Update-withNewDate-test2", |
| 349 | runTest: function(){ |
| 350 | var day2 = new Date(1993, 9, 28, 1, 0, 0, 0); // 10/28/1993 |
| 351 | registry.byId(test2_cal).set("value", day2); |
| 352 | doh.is("1993", registry.byId("test2_cal").get("value").getFullYear(),"test2_cal getFullYear should be 1993"); |
| 353 | doh.is("9", registry.byId("test2_cal").get("value").getMonth(),"test2_cal getMonth should be 9"); |
| 354 | doh.is("28", registry.byId("test2_cal").get("value").getDate(),"test2_cal getDate should be 28"); |
| 355 | doh.is("1993", registry.byId("test2_cal2").get("value").getFullYear(),"test2_cal2 getFullYear should be 1993"); |
| 356 | doh.is("9", registry.byId("test2_cal2").get("value").getMonth(),"test2_cal2 getMonth should be 9"); |
| 357 | doh.is("28", registry.byId("test2_cal2").get("value").getDate(),"test2_cal2 getDate should be 28"); |
| 358 | doh.is("10-28-1993 1:00 AM", registry.byId("test2_txt2").get("value"), "test2_txt2 should be 10-28-1993 1:00 AM"); |
| 359 | doh.is("10-28-1993 1:00 AM", registry.byId("test2_output2").get("value"), "test2_output2 should be 10-28-1993 1:00 AM"); |
| 360 | } |
| 361 | }, { |
| 362 | name: "Update-withNewDate-test3", |
| 363 | runTest: function(){ |
| 364 | var day2 = new Date(1993, 9, 28, 1, 0, 0, 0); // 10/28/1993 |
| 365 | registry.byId(test3_cal).set("value", day2); |
| 366 | doh.is("1993", registry.byId("test3_cal").get("value").getFullYear(),"test3_cal getFullYear should be 1993"); |
| 367 | doh.is("9", registry.byId("test3_cal").get("value").getMonth(),"test3_cal getMonth should be 9"); |
| 368 | doh.is("28", registry.byId("test3_cal").get("value").getDate(),"test3_cal getDate should be 28"); |
| 369 | doh.is("1993", registry.byId("test3_cal2").get("value").getFullYear(),"test3_cal2 getFullYear should be 1993"); |
| 370 | doh.is("9", registry.byId("test3_cal2").get("value").getMonth(),"test3_cal2 getMonth should be 9"); |
| 371 | doh.is("28", registry.byId("test3_cal2").get("value").getDate(),"test3_cal2 getDate should be 28"); |
| 372 | doh.is("10-28-1993 1:00 AM", registry.byId("test3_txt2").get("value"), "test3_txt2 should be 10-28-1993 1:00 AM"); |
| 373 | doh.is("10-28-1993 1:00 AM", registry.byId("test3_output2").get("value"), "test3_output2 should be 10-28-1993 1:00 AM"); |
| 374 | } |
| 375 | }]); |
| 376 | |
| 377 | doh.register("Check model reset", [{ |
| 378 | name: "Reset-test1", |
| 379 | runTest: function(){ |
| 380 | test1_ctrl.reset(); |
| 381 | doh.is("1987", registry.byId("test1_cal").get("value").getFullYear(),"test1_cal getFullYear should be 1987"); |
| 382 | doh.is("7", registry.byId("test1_cal").get("value").getMonth(),"test1_cal getMonth should be 7"); |
| 383 | doh.is("1", registry.byId("test1_cal").get("value").getDate(),"test1_cal getDate should be 1"); |
| 384 | doh.is("1987", registry.byId("test1_cal2").get("value").getFullYear(),"test1_cal2 getFullYear should be 1987"); |
| 385 | doh.is("7", registry.byId("test1_cal2").get("value").getMonth(),"test1_cal2 getMonth should be 7"); |
| 386 | doh.is("1", registry.byId("test1_cal2").get("value").getDate(),"test1_cal2 getDate should be 1"); |
| 387 | doh.is("08-01-1987 1:00 AM", registry.byId("test1_txt2").get("value"), "test1_txt2 should be 08-01-1987 1:00 AM"); |
| 388 | doh.is("08-01-1987 1:00 AM", registry.byId("test1_output2").get("value"), "test1_output2 should be 08-01-1987 1:00 AM"); |
| 389 | } |
| 390 | }, { |
| 391 | name: "Reset-test2", |
| 392 | runTest: function(){ |
| 393 | test2_ctrl.reset(); |
| 394 | doh.is("2011", registry.byId("test2_cal").get("value").getFullYear(),"test2_cal getFullYear should be 1987"); |
| 395 | doh.is("10", registry.byId("test2_cal").get("value").getMonth(),"test2_cal getMonth should be 10"); |
| 396 | doh.is("6", registry.byId("test2_cal").get("value").getDate(),"test2_cal getDate should be 6"); |
| 397 | doh.is("2011", registry.byId("test2_cal2").get("value").getFullYear(),"test2_cal2 getFullYear should be 1987"); |
| 398 | doh.is("10", registry.byId("test2_cal2").get("value").getMonth(),"test2_cal2 getMonth should be 10"); |
| 399 | doh.is("6", registry.byId("test2_cal2").get("value").getDate(),"test2_cal2 getDate should be 6"); |
| 400 | doh.is("11-06-2011 1:00 AM", registry.byId("test2_txt2").get("value"), "test2_txt2 should be 11-06-2011 1:00 AM"); |
| 401 | doh.is("11-06-2011 1:00 AM", registry.byId("test2_output2").get("value"), "test2_output2 should be 11-06-2011 1:00 AM"); |
| 402 | } |
| 403 | }, { |
| 404 | name: "Reset-test3", |
| 405 | runTest: function(){ |
| 406 | test3_ctrl.reset(); |
| 407 | doh.is("2011", registry.byId("test3_cal").get("value").getFullYear(),"test3_cal getFullYear should be 1987"); |
| 408 | doh.is("7", registry.byId("test3_cal").get("value").getMonth(),"test3_cal getMonth should be 7"); |
| 409 | doh.is("27", registry.byId("test3_cal").get("value").getDate(),"test3_cal getDate should be 27"); |
| 410 | doh.is("2011", registry.byId("test3_cal2").get("value").getFullYear(),"test3_cal2 getFullYear should be 1987"); |
| 411 | doh.is("7", registry.byId("test3_cal2").get("value").getMonth(),"test3_cal2 getMonth should be 7"); |
| 412 | doh.is("27", registry.byId("test3_cal2").get("value").getDate(),"test3_cal2 getDate should be 27"); |
| 413 | doh.is("08-27-2011 1:00 AM", registry.byId("test3_txt2").get("value"), "test3_txt2 should be 08-27-2011 1:00 AM"); |
| 414 | doh.is("08-27-2011 1:00 AM", registry.byId("test3_output2").get("value"), "test3_output2 should be 08-27-2011 1:00 AM"); |
| 415 | } |
| 416 | }]); |
| 417 | |
| 418 | doh.register("Test misc in model", [{ |
| 419 | name: "Regexp-test4", |
| 420 | runTest: function(){ |
| 421 | doh.is("/abc/i", test4_ctrl.get("regex"),"test4_ctrl.get(\"regex\") should be /abc/i"); |
| 422 | var str = "ABCDEFGHIJKLMNOP abcdefghi"; |
| 423 | var patt1 = test4_ctrl.get("regex"); |
| 424 | doh.is("ABC", str.match(test4_ctrl.get("regex")),"str.match(test4_ctrl.get(\"regex\")) should be ABC"); |
| 425 | doh.is("ABC", str.match(patt1),"str.match(patt1) should be ABC"); |
| 426 | test4_ctrl.set("regex",/def/); |
| 427 | doh.is("def", str.match(test4_ctrl.get("regex")),"str.match(test4_ctrl.get(\"regex\")) after set /def/ should be def"); |
| 428 | test4_ctrl.reset(); |
| 429 | doh.is("ABC", str.match(test4_ctrl.get("regex")),"str.match(test4_ctrl.get(\"regex\")) after reset should be ABC"); |
| 430 | } |
| 431 | }, { |
| 432 | name: "Falsy-test5", |
| 433 | runTest: function(){ |
| 434 | doh.t(null === test5_model.get("n"),"test5_model.get(\"n\") should be null"); |
| 435 | doh.t(0 === test5_model.get("z"),"test5_model.get(\"z\") should be 0"); |
| 436 | doh.t(undefined === test5_model.get("u"),"test5_model.get(\"u\") should be undefined"); |
| 437 | doh.t(false === test5_model.get("f"),"test5_model.f.get(\"f\") should be false"); |
| 438 | doh.t("" === test5_model.get("s"),"test5_model.s.get(\"s\") should be an empty string"); |
| 439 | } |
| 440 | }]); |
| 441 | |
| 442 | doh.run(); |
| 443 | }); |
| 444 | </script> |
| 445 | </head> |
| 446 | <body class="claro"> |
| 447 | <h2>Test 1: Two Calendars bound to each other, a TextBox and an mvc Output field.</h2> |
| 448 | <div style="border-style: solid; border-width: 2px; width: 827px;"> |
| 449 | <table> |
| 450 | <tbody> |
| 451 | <tr> |
| 452 | <td><div id="test1_cal"></div></td> |
| 453 | <td><div id="test1_cal2"></div></td> |
| 454 | <td> |
| 455 | <table> |
| 456 | <tbody> |
| 457 | <tr><td><label for="test1_txt2">TextBox bound to date:</label></td></tr> |
| 458 | <tr><td><div id="test1_txt2"></div></td></tr> |
| 459 | <tr><td><label for="test1_txt2">MVC Output bound to date:</label></td></tr> |
| 460 | <tr><td><div id="test1_output2"></div></td></tr> |
| 461 | </tbody> |
| 462 | </table> |
| 463 | <table> |
| 464 | <tbody> |
| 465 | <tr> |
| 466 | <td><div id="test1_setdate1"></div></td> |
| 467 | </tr> |
| 468 | </tbody> |
| 469 | </table> |
| 470 | <table> |
| 471 | <tbody> |
| 472 | <tr> |
| 473 | <td><div id="test1_setdate2"></div></td> |
| 474 | </tr> |
| 475 | </tbody> |
| 476 | </table> |
| 477 | <table> |
| 478 | <tbody> |
| 479 | <tr> |
| 480 | <td><div id="test1_setdate3"></div></td> |
| 481 | </tr> |
| 482 | </tbody> |
| 483 | </table> |
| 484 | <table> |
| 485 | <tbody> |
| 486 | <tr> |
| 487 | <td><div id="test1_reset2"></div></td> |
| 488 | </tr> |
| 489 | </tbody> |
| 490 | </table> |
| 491 | </td> |
| 492 | </tr> |
| 493 | </tbody> |
| 494 | </table> |
| 495 | </div> |
| 496 | |
| 497 | <h2>Test 2: Two DateTextBoxes bound to each other, a TextBox and an mvc Output field.</h2> |
| 498 | <div style="border-style: solid; border-width: 2px; width: 827px;"> |
| 499 | <table> |
| 500 | <tbody> |
| 501 | <tr> |
| 502 | <td style="vertical-align: top;"><div id="test2_cal"></div></td> |
| 503 | <td style="vertical-align: top;"><div id="test2_cal2"></div></td> |
| 504 | <td> |
| 505 | <table> |
| 506 | <tbody> |
| 507 | <tr><td><label for="test2_txt2">TextBox bound to date:</label></td></tr> |
| 508 | <tr><td><div id="test2_txt2"></div></td></tr> |
| 509 | <tr><td><label for="test2_txt2">MVC Output bound to date:</label></td></tr> |
| 510 | <tr><td><div id="test2_output2"></div></td></tr> |
| 511 | </tbody> |
| 512 | </table> |
| 513 | <table> |
| 514 | <tbody> |
| 515 | <tr> |
| 516 | <td><div id="test2_setdate1"></div></td> |
| 517 | </tr> |
| 518 | </tbody> |
| 519 | </table> |
| 520 | <table> |
| 521 | <tbody> |
| 522 | <tr> |
| 523 | <td><div id="test2_setdate2"></div></td> |
| 524 | </tr> |
| 525 | </tbody> |
| 526 | </table> |
| 527 | <table> |
| 528 | <tbody> |
| 529 | <tr> |
| 530 | <td><div id="test2_setdate3"></div></td> |
| 531 | </tr> |
| 532 | </tbody> |
| 533 | </table> |
| 534 | <table> |
| 535 | <tbody> |
| 536 | <tr> |
| 537 | <td><div id="test2_reset2"></div></td> |
| 538 | </tr> |
| 539 | </tbody> |
| 540 | </table> |
| 541 | </td> |
| 542 | </tr> |
| 543 | </tbody> |
| 544 | </table> |
| 545 | </div> |
| 546 | <h2>Test 3: One Calendar bound to a DateTextbox, a TextBox and an mvc Output field.</h2> |
| 547 | <div style="border-style: solid; border-width: 2px; width: 827px;"> |
| 548 | <table> |
| 549 | <tbody> |
| 550 | <tr> |
| 551 | <td style="vertical-align: top;"><div id="test3_cal"></div></td> |
| 552 | <td style="vertical-align: top;"><div id="test3_cal2"></div></td> |
| 553 | <td> |
| 554 | <table> |
| 555 | <tbody> |
| 556 | <tr><td><label for="test3_txt2">TextBox bound to date: (disabled to avoid error)</label></td></tr> |
| 557 | <tr><td><div id="test3_txt2"></div></td></tr> |
| 558 | <tr><td><label for="test3_txt2">MVC Output bound to date:</label></td></tr> |
| 559 | <tr><td><div id="test3_output2"></div></td></tr> |
| 560 | </tbody> |
| 561 | </table> |
| 562 | <table> |
| 563 | <tbody> |
| 564 | <tr> |
| 565 | <td><div id="test3_setdate1"></div></td> |
| 566 | </tr> |
| 567 | </tbody> |
| 568 | </table> |
| 569 | <table> |
| 570 | <tbody> |
| 571 | <tr> |
| 572 | <td><div id="test3_setdate2"></div></td> |
| 573 | </tr> |
| 574 | </tbody> |
| 575 | </table> |
| 576 | <table> |
| 577 | <tbody> |
| 578 | <tr> |
| 579 | <td><div id="test3_setdate3"></div></td> |
| 580 | </tr> |
| 581 | </tbody> |
| 582 | </table> |
| 583 | <table> |
| 584 | <tbody> |
| 585 | <tr> |
| 586 | <td><div id="test3_reset2"></div></td> |
| 587 | </tr> |
| 588 | </tbody> |
| 589 | </table> |
| 590 | </td> |
| 591 | </tr> |
| 592 | </tbody> |
| 593 | </table> |
| 594 | </div> |
| 595 | </body> |
| 596 | </html> |