Commit 4c7e68d3 authored by Ivan Tyagov's avatar Ivan Tyagov

Extend API and add testing for it.

parent 9e95412f
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</item> </item>
<item> <item>
<key> <string>_EtagSupport__etag</string> </key> <key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts36997821.03</string> </value> <value> <string>ts37002880.65</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -520,13 +520,20 @@ var GadgetIndex = {\n ...@@ -520,13 +520,20 @@ var GadgetIndex = {\n
},\n },\n
\n \n
registerGadget: function(gadget) {\n registerGadget: function(gadget) {\n
/* Register gadget */\n /*\n
* Register gadget\n
*/\n
this.gadget_list.push(gadget);\n this.gadget_list.push(gadget);\n
},\n },\n
\n \n
unregisterGadget: function(gadget) {\n unregisterGadget: function(gadget) {\n
/* Unregister gadget */\n /*\n
// XXX:\n * Unregister gadget\n
*/\n
index = jQuery.inArray(gadget, this.gadget_list);\n
if (index!=-1) {\n
this.gadget_list.splice(index, 1);\n
} \n
},\n },\n
\n \n
getGadgetById: function (gadget_id){\n getGadgetById: function (gadget_id){\n
...@@ -718,7 +725,7 @@ var RenderJs = {\n ...@@ -718,7 +725,7 @@ var RenderJs = {\n
is_gadget_list_loaded = GadgetIndex.isGadgetListLoaded();\n is_gadget_list_loaded = GadgetIndex.isGadgetListLoaded();\n
if (is_gadget_list_loaded){\n if (is_gadget_list_loaded){\n
if (!is_ready) {\n if (!is_ready) {\n
console.log("trigger");\n //console.log("trigger");\n
GadgetIndex.getRootGadget().getDom().trigger("ready");\n GadgetIndex.getRootGadget().getDom().trigger("ready");\n
}\n }\n
is_ready = true;\n is_ready = true;\n
...@@ -762,7 +769,7 @@ var RenderJs = {\n ...@@ -762,7 +769,7 @@ var RenderJs = {\n
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>25230</int> </value> <value> <int>25373</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_EtagSupport__etag</string> </key> <key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts33622213.73</string> </value> <value> <string>ts37003035.66</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
</item> </item>
<item> <item>
<key> <string>data</string> </key> <key> <string>data</string> </key>
<value> <string>function setupRenderJSTest(){\n <value> <string encoding="cdata"><![CDATA[
function setupRenderJSTest(){\n
/*\n /*\n
* Main RenderJS test entry point\n * Main RenderJS test entry point\n
*/\n */\n
...@@ -32,15 +34,45 @@ ...@@ -32,15 +34,45 @@
deepEqual(data, Cache.get(cache_id));\n deepEqual(data, Cache.get(cache_id));\n
});\n });\n
\n \n
\n
module("TabularGadget");\n module("TabularGadget");\n
test(\'addNewTabGadget\', function(){\n test(\'addNewTabGadget\', function(){\n
TabbularGadget.addNewTabGadget("Person_view", "qunit-fixture", "FormUpdater.update");\n TabbularGadget.addNewTabGadget("Person_view", "qunit-fixture", "FormUpdater.update");\n
equal($("#qunit-fixture").children(".gadget").length, 1);\n equal($("#qunit-fixture").children(".gadget").length, 1);\n
equal(GadgetIndex.getGadgetList().length, 1);\n
\n
});\n
\n
module("GadgetIndex");\n
test(\'GadgetIndex\', function(){\n
// re-init GadgetIndex\n
$.each(GadgetIndex.getGadgetList(), function () {\n
GadgetIndex.unregisterGadget(this);\n
});\n
\n
$("#qunit-fixture").append(\'<div gadget="" id="new">XXXXXXXXXXXX</div>\');\n
RenderJs.bootstrap($("#qunit-fixture"));\n
GadgetIndex.getRootGadget().getDom().one("ready", function (){\n
RenderJs.update($("#qunit-fixture"));\n
});\n
equal(GadgetIndex.getGadgetList().length, 2);\n
equal(true, GadgetIndex.isGadgetListLoaded());\n
equal($("#qunit-fixture").attr("id"), GadgetIndex.getRootGadget().getDom().attr("id"));\n
equal(GadgetIndex.getGadgetById("qunit-fixture"), GadgetIndex.getRootGadget());\n
\n
// unregister gadget\n
GadgetIndex.unregisterGadget(GadgetIndex.getGadgetById("qunit-fixture"));\n
equal(GadgetIndex.getGadgetList().length, 1);\n
equal(GadgetIndex.getGadgetById("new"), GadgetIndex.getRootGadget());\n
\n
\n
});\n });\n
\n \n
};\n };\n
\n \n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>precondition</string> </key> <key> <string>precondition</string> </key>
...@@ -48,7 +80,7 @@ ...@@ -48,7 +80,7 @@
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>545</int> </value> <value> <int>1755</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
12 13
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment