Debian Codegraph @

dojox/mvc/tests/doh/equals.js

raw symbols SCIP
1 define([
2 "doh",
3 "dojox/mvc/getStateful",
4 "dojox/mvc/equals"
5 ], function(doh, getStateful, equals){
6 var a = [
7 {
8 uniqueId: 0,
9 Completed: false,
10 Subject: "Pick up my kids",
11 Due: new Date((new Date()).getTime() + 48 * 3600000),
12 Priority: 1,
13 Description: "At the kindergarden"
14 },
15 {
16 uniqueId: 1,
17 Completed: true,
18 Subject: "Take dojox.mvc learning course",
19 Due: new Date((new Date()).getTime() + 72 * 3600000),
20 Priority: 2,
21 Description: "Need to find course material at http://dojotoolkit.org/"
22 },
23 {
24 uniqueId: 2,
25 Completed: false,
26 Subject: "Wash my car",
27 Due: new Date((new Date()).getTime() + 120 * 3600000),
28 Priority: 3,
29 Description: "Need to buy a cleaner before that"
30 }
31 ];
32
33 doh.register("dojox.mvc.tests.doh.equals", [
34 function equalsSimple(){
35 doh.t(equals(getStateful(a), getStateful(a)), "Two stateful object from the same data source should be equal");
36 },
37 function changeValue(){
38 var dst = getStateful(a), src = getStateful(a);
39 src[1].set("Priority", 3);
40 doh.f(equals(dst, src), "equals() should catch the change");
41 src[1].set("Priority", 2);
42 doh.t(equals(dst, src), "equals() should catch the change in src back to original");
43 },
44 function changeDate(){
45 var dst = getStateful(a), src = getStateful(a), d;
46 (d = new Date()).setTime(src[1].get("Due").getTime() + 72 * 3600000);
47 src[1].set("Due", d);
48 doh.f(equals(dst, src), "equals() should catch the change");
49 (d = new Date()).setTime(src[1].get("Due").getTime() - 72 * 3600000);
50 src[1].set("Due", d);
51 doh.t(equals(dst, src), "equals() should catch the change in src back to original");
52 }
53 ]);
54 });