Commit b2b89799 authored by Ivan Tyagov's avatar Ivan Tyagov

Add gadget's proper initialization from data-gadget-property test.

parent 790d533a
/*
* RenderJs tests
*/
function setupRenderJSTest(){ function setupRenderJSTest(){
/* /*
* Main RenderJS test entry point * Main RenderJS test entry point
*/ */
module("Cache"); module("Cache");
test('Cache', function(){ test('Cache', function () {
cache_id = 'my_test'; cache_id = 'my_test';
data = {'gg':1}; data = {'gg':1};
RenderJs.Cache.set(cache_id, data); RenderJs.Cache.set(cache_id, data);
...@@ -13,7 +15,7 @@ function setupRenderJSTest(){ ...@@ -13,7 +15,7 @@ function setupRenderJSTest(){
}); });
module("GadgetIndex"); module("GadgetIndex");
test('GadgetIndex', function(){ test('GadgetIndex', function () {
// re-init GadgetIndex // re-init GadgetIndex
$.each(RenderJs.GadgetIndex.getGadgetList(), function () { $.each(RenderJs.GadgetIndex.getGadgetList(), function () {
RenderJs.GadgetIndex.unregisterGadget(this); RenderJs.GadgetIndex.unregisterGadget(this);
...@@ -38,12 +40,29 @@ function setupRenderJSTest(){ ...@@ -38,12 +40,29 @@ function setupRenderJSTest(){
}); });
module("TabularGadget"); module("TabularGadget");
test('addNewTabGadget', function(){ test('addNewTabGadget', function () {
RenderJs.TabbularGadget.addNewTabGadget("qunit-fixture", "test-gadget.html", "", ""); RenderJs.TabbularGadget.addNewTabGadget("qunit-fixture", "test-gadget.html", "", "");
equal($("#qunit-fixture").children(".gadget").length, 1); equal($("#qunit-fixture").children(".gadget").length, 1);
equal(RenderJs.GadgetIndex.getGadgetList().length, 1); equal(RenderJs.GadgetIndex.getGadgetList().length, 1);
}); });
module("GadgetInitialization");
test('GadgetInitialization', function () {
// re-init GadgetIndex
$.each(RenderJs.GadgetIndex.getGadgetList(), function () {
RenderJs.GadgetIndex.unregisterGadget(this);
});
$("#qunit-fixture").append('<div data-gadget="" id="new-init" data-gadget-property="{&quot;name&quot;: &quot;Ivan&quot;, &quot;age&quot;: 33}">XXXXXXXXXXXX</div>');
RenderJs.bootstrap($("#qunit-fixture"));
RenderJs.GadgetIndex.getRootGadget().getDom().one("ready", function (){
RenderJs.update($("#qunit-fixture"));
});
// test that gadget get a proper initialization from data-gadget-property
equal('Ivan', RenderJs.GadgetIndex.getGadgetById("new-init").name);
equal(33, RenderJs.GadgetIndex.getGadgetById("new-init").age);
});
// XXX: test InteractionGadget // XXX: test InteractionGadget
}; };
......
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