Debian Codegraph @

dijit/tests/tree/Tree_with_JRS.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html lang="en">
4 <head>
5 <title>dijit/Tree with dojox/data/JsonRestStore automated test</title>
6
7 <script type="text/javascript" src="../boilerplate.js"></script>
8
9 <script type="text/javascript">
10 require([
11 "doh/runner",
12 "dojo/dom",
13 "dojo/on",
14 "dijit/Tree",
15 "dijit/tree/ForestStoreModel",
16 "dijit/tree/dndSource",
17 "dojox/data/JsonRestStore",
18 "dojo/domReady!"
19 ], function(doh, dom, on, Tree, ForestStoreModel, dndSource, JsonRestStore){
20
21 var myTree;
22
23 doh.register("Tree with dojox/data/JsonRestStore test", [
24 {
25 timeout: 3000,
26 name: "create",
27 runTest: function(){
28 var
29 d = new doh.Deferred(),
30 myStore = new JsonRestStore({target:"./", labelAttribute:"name"}),
31 myModel = new ForestStoreModel({
32 store: myStore,
33 deferItemLoadingUntilExpand: true,
34 query: "treeTestRoot",
35 childrenAttrs: ["children"]
36 });
37 myTree = new Tree({
38 id: "myTree",
39 model: myModel,
40 label: "Example",
41 persist: false, // persist==true is too hard to test
42 dndController: "dijit.tree.dndSource"
43 });
44 doh.t(myTree, "tree created");
45
46 dom.byId("container").appendChild(myTree.domNode);
47 myTree.startup();
48 myTree.onLoadDeferred.then(d.getTestCallback(function(){
49 // Give the tree time to load, and the do checks that it
50 // loaded correctly
51 doh.t(myTree.rootNode, "root node exists");
52 doh.t(myTree.rootNode.isExpanded, "root node is expanded");
53
54 var children = myTree.rootNode.getChildren();
55 doh.is(5, children.length, "six children");
56 doh.is("node1", children[0].label, "first child");
57 doh.f(children[0].isExpanded, "first child not expanded");
58 }));
59 return d;
60 }
61 },
62 {
63 timeout: 2000,
64 name: "open a node",
65 runTest: function(){
66 var d = new doh.Deferred(),
67 first = myTree.rootNode.getChildren()[0];
68
69 on.emit(first.expandoNode, "click", {bubbles: true});
70
71 setTimeout(d.getTestErrback(function(){
72 var firstFirst = first.getChildren()[0];
73 on.emit(firstFirst.expandoNode, "click", {bubbles: true});
74 setTimeout(d.getTestCallback(function(){
75 var children = firstFirst.getChildren();
76 doh.is(2, children.length, "two children");
77 doh.is("node1.1.1", children[0].label, "first child");
78 }), 750);
79 }), 750);
80
81 return d;
82 }
83 }
84 ]);
85
86 doh.run();
87 });
88 </script>
89
90 </head>
91 <body class="claro" role="main">
92 <h1 class="testTitle">dijit/Tree with dojox/data/JsonRestStore automated test</h1>
93 <div id="container"> <!-- tree will go here --></div>
94 <div id="container2"> <!-- tree2 will go here --></div>
95 </body>
96 </html>