From: Michael Wood Date: Fri, 9 Oct 2015 09:32:43 +0000 (+0100) Subject: toaster: Update JS unit tests X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=46af40b95f842aa14ef7e3f0d516aef3899d5e42;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git toaster: Update JS unit tests Update JS unit tests. - Expand the add remove layer check to make sure that the layer is actually added to the project. - Remove some unused vars - Make sure that the layers/project ids will always exist at the point of running the test. - Add the missing typeahead input fields to the dom to fix the failing typeahead test. Signed-off-by: Michael Wood Signed-off-by: Elliot Smith Signed-off-by: Richard Purdie --- diff --git a/lib/toaster/toastergui/static/js/tests/test.js b/lib/toaster/toastergui/static/js/tests/test.js index f0df6e4ac10..aac0ba60a21 100644 --- a/lib/toaster/toastergui/static/js/tests/test.js +++ b/lib/toaster/toastergui/static/js/tests/test.js @@ -13,8 +13,6 @@ QUnit.test("Layer alert notification", function(assert) { "name":"meta-example" }; - var correctResponse = "You have added 3 layers to your project: meta-example and its dependencies meta-example-two, meta-example-three"; - var layerDepsList = [ { "layerdetailurl":"/toastergui/project/1/layer/9", @@ -68,9 +66,9 @@ QUnit.test("Show notification", function(assert){ }); var layer = { - "id": 91, - "name": "meta-crystalforest", - "layerdetailurl": "/toastergui/project/4/layer/91" + "id": 1, + "name": "meta-testing", + "layerdetailurl": "/toastergui/project/1/layer/1" }; QUnit.test("Add layer", function(assert){ @@ -84,11 +82,19 @@ QUnit.test("Add layer", function(assert){ } }, 200); - libtoaster.addRmLayer(layer, true, function(deps){ - assert.equal(deps.length, 1); - done(); + /* Compare the number of layers before and after the add in the project */ + libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, function(prjInfo){ + var origNumLayers = prjInfo.layers.length; + + libtoaster.addRmLayer(layer, true, function(deps){ + libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, + function(prjInfo){ + assert.ok(prjInfo.layers.length > origNumLayers, + "Layer not added to project"); + done(); + }); + }); }); - }); QUnit.test("Rm layer", function(assert){ @@ -156,7 +162,7 @@ QUnit.test("Layer btns init", function(assert){ }); QUnit.test("Table init", function(assert){ - assert.throws(tableInit({ url : tableUrl })); + assert.throws(tableInit({ url : ctx.tableUrl })); }); $(document).ajaxError(function(event, jqxhr, settings, errMsg){ @@ -167,9 +173,3 @@ $(document).ajaxError(function(event, jqxhr, settings, errMsg){ assert.notOk(jqxhr.responseText); }); }); - - - - - - diff --git a/lib/toaster/toastergui/templates/js-unit-tests.html b/lib/toaster/toastergui/templates/js-unit-tests.html index 5b8fd84470a..8d65f33cb1e 100644 --- a/lib/toaster/toastergui/templates/js-unit-tests.html +++ b/lib/toaster/toastergui/templates/js-unit-tests.html @@ -22,9 +22,11 @@ -
@@ -34,6 +36,12 @@ -{% endblock %} - + + + + + + + +{% endblock %}