Commit 8e35bd3c authored by Ivan Tyagov's avatar Ivan Tyagov

Improve testing.

Handle cases when for gadget_data_source and gadget_data_handler we have
empty strings.
parent 16ed8029
...@@ -150,7 +150,7 @@ var RenderJs = (function () { ...@@ -150,7 +150,7 @@ var RenderJs = (function () {
data_source = gadget.attr("data-gadget:data-source"); data_source = gadget.attr("data-gadget:data-source");
data_handler = gadget.attr("data-gadget:data-handler"); data_handler = gadget.attr("data-gadget:data-handler");
// acquire data and pass it to method handler // acquire data and pass it to method handler
if (data_source!==undefined){ if (data_source!==undefined && data_source!==""){
$.ajax({url:data_source, $.ajax({url:data_source,
dataType: "json", dataType: "json",
yourCustomData: {"data_handler": data_handler}, yourCustomData: {"data_handler": data_handler},
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
<h1 id="qunit-header">QUnit RenderJS test suite</h1> <h1 id="qunit-header">QUnit RenderJS test suite</h1>
<h2 id="qunit-banner"></h2> <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2> <h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"> <ol id="qunit-tests"></ol>
</ol>
<div id="qunit-fixture"> </div> <div id="qunit-fixture"> </div>
<script type="text/javascript"> <script type="text/javascript">
......
...@@ -12,14 +12,6 @@ function setupRenderJSTest(){ ...@@ -12,14 +12,6 @@ function setupRenderJSTest(){
deepEqual(data, RenderJs.Cache.get(cache_id)); deepEqual(data, RenderJs.Cache.get(cache_id));
}); });
module("TabularGadget");
test('addNewTabGadget', function(){
RenderJs.TabbularGadget.addNewTabGadget("qunit-fixture", "test-gadget.xhtml");
equal($("#qunit-fixture").children(".gadget").length, 1);
equal(RenderJs.GadgetIndex.getGadgetList().length, 1);
});
module("GadgetIndex"); module("GadgetIndex");
test('GadgetIndex', function(){ test('GadgetIndex', function(){
// re-init GadgetIndex // re-init GadgetIndex
...@@ -37,12 +29,19 @@ function setupRenderJSTest(){ ...@@ -37,12 +29,19 @@ function setupRenderJSTest(){
equal($("#qunit-fixture").attr("id"), RenderJs.GadgetIndex.getRootGadget().getDom().attr("id")); equal($("#qunit-fixture").attr("id"), RenderJs.GadgetIndex.getRootGadget().getDom().attr("id"));
equal(RenderJs.GadgetIndex.getGadgetById("qunit-fixture"), RenderJs.GadgetIndex.getRootGadget()); equal(RenderJs.GadgetIndex.getGadgetById("qunit-fixture"), RenderJs.GadgetIndex.getRootGadget());
// unregister gadget // unregister gadget all gadgets from this test not to mess with rest of tests
RenderJs.GadgetIndex.unregisterGadget(RenderJs.GadgetIndex.getGadgetById("qunit-fixture")); RenderJs.GadgetIndex.unregisterGadget(RenderJs.GadgetIndex.getGadgetById("qunit-fixture"));
equal(RenderJs.GadgetIndex.getGadgetList().length, 1); equal(RenderJs.GadgetIndex.getGadgetList().length, 1);
equal(RenderJs.GadgetIndex.getGadgetById("new"), RenderJs.GadgetIndex.getRootGadget()); equal(RenderJs.GadgetIndex.getGadgetById("new"), RenderJs.GadgetIndex.getRootGadget());
RenderJs.GadgetIndex.unregisterGadget(RenderJs.GadgetIndex.getGadgetById("new"));
equal(RenderJs.GadgetIndex.getGadgetList().length, 0);
});
module("TabularGadget");
test('addNewTabGadget', function(){
RenderJs.TabbularGadget.addNewTabGadget("qunit-fixture", "test-gadget.html", "", "");
equal($("#qunit-fixture").children(".gadget").length, 1);
equal(RenderJs.GadgetIndex.getGadgetList().length, 1);
}); });
}; };
......
test!!!
\ No newline at end of file
test!!!
<div id="test-container">
</div>
\ 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