From 952acfc8fbe67b932307945378e112332e8b43a2 Mon Sep 17 00:00:00 2001 From: Tira Odhner Date: Mon, 20 Mar 2017 17:48:04 -0400 Subject: [PATCH 2/3] Hide the spinner once the acitree is initialized --- web/pgadmin/static/js/handle_acitree_events.js | 4 +- .../javascript/handle_acitree_events_spec.js | 43 ++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 web/regression/javascript/handle_acitree_events_spec.js diff --git a/web/pgadmin/static/js/handle_acitree_events.js b/web/pgadmin/static/js/handle_acitree_events.js index 99f9b0fe..b33dea66 100644 --- a/web/pgadmin/static/js/handle_acitree_events.js +++ b/web/pgadmin/static/js/handle_acitree_events.js @@ -7,7 +7,7 @@ * **************************************************************************/ -define(['sources/translate'], function (translate) { +define(['sources/translate', 'jquery'], function (translate, $) { return function (event, api, item, eventName, options) { var obj = this; var d = item ? obj.tree.itemData(item) : null; @@ -63,6 +63,8 @@ define(['sources/translate'], function (translate) { } } break; + case "init": + $('#pg-spinner').remove(); } diff --git a/web/regression/javascript/handle_acitree_events_spec.js b/web/regression/javascript/handle_acitree_events_spec.js new file mode 100644 index 00000000..3b2f0e72 --- /dev/null +++ b/web/regression/javascript/handle_acitree_events_spec.js @@ -0,0 +1,43 @@ +/************************************************************************* + * + * pgAdmin 4 - PostgreSQL Tools + * + * Copyright (C) 2013 - 2017, The pgAdmin Development Team + * This software is released under the PostgreSQL Licence + * + **************************************************************************/ + +define(['jquery', 'sources/handle_acitree_events'], function ($, handleTree) { + describe("#handleAciTreeEvents", function () { + var spinnerPanel, obj; + + beforeEach(function () { + spinnerPanel = $('
')[0]; + document.body.appendChild(spinnerPanel); + + obj = { + tree: { + itemData: function () { + + } + } + }; + }); + + afterEach(function () { + if ($('#pg-spinner').length != 0) { + document.body.removeChild(spinnerPanel); + } + }); + + describe("when an init event happens", function () { + it("hides the spinner", function () { + expect($('#pg-spinner').length).toBe(1); + handleTree.apply(obj, [{}, {}, {}, 'init']); + expect($('#pg-spinner').length).toBe(0); + + }); + }); + }); + } +); \ No newline at end of file -- 2.12.0