Repository: ambari Updated Branches: refs/heads/trunk 90cca9bba -> 1cd81bec5
AMBARI-7520. Fix UI Unit tests. (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9e2a81d6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9e2a81d6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9e2a81d6 Branch: refs/heads/trunk Commit: 9e2a81d61829a6b29c0fae75fa4b27d3c0a1ba44 Parents: 8959037 Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Fri Sep 26 17:13:11 2014 +0300 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Fri Sep 26 17:13:11 2014 +0300 ---------------------------------------------------------------------- .../main/service/info/config_test.js | 61 +------------------- .../test/controllers/wizard/step7_test.js | 46 ++++++++------- ambari-web/test/models/run_test.js | 10 ---- ambari-web/test/utils/date_test.js | 40 ------------- 4 files changed, 25 insertions(+), 132 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9e2a81d6/ambari-web/test/controllers/main/service/info/config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js index 8926cf2..e11ad38 100644 --- a/ambari-web/test/controllers/main/service/info/config_test.js +++ b/ambari-web/test/controllers/main/service/info/config_test.js @@ -167,65 +167,6 @@ describe("App.MainServiceInfoConfigsController", function () { }); }); - describe("#selectConfigGroup", function () { - - var tests = [ - { - event: { - context: "cfgGroup" - }, - isInit: true, - showPopup: false, - m: "setup new cfg group" - }, - { - event: { - context: "cfgGroup" - }, - isInit: false, - hash: "hash", - showPopup: false, - m: "setup new cfg group, has some changes" - }, - { - event: { - context: "cfgGroup" - }, - isInit: false, - hash: "hash1", - showPopup: true, - m: "show popup, doesn't setup new cfg group" - } - ]; - - beforeEach(function () { - sinon.stub(mainServiceInfoConfigsController, "showSavePopup", Em.K); - sinon.stub(mainServiceInfoConfigsController, "getHash", function () { - return "hash" - }); - sinon.stub(mainServiceInfoConfigsController, "onConfigGroupChange", Em.K); - }); - afterEach(function () { - mainServiceInfoConfigsController.showSavePopup.restore(); - mainServiceInfoConfigsController.getHash.restore(); - mainServiceInfoConfigsController.onConfigGroupChange.restore(); - }); - tests.forEach(function (t) { - it(t.m, function () { - mainServiceInfoConfigsController.set("isInit", t.isInit); - mainServiceInfoConfigsController.set("hash", t.hash); - mainServiceInfoConfigsController.selectConfigGroup(t.event); - if (!t.showPopup) { - expect(mainServiceInfoConfigsController.get("selectedConfigGroup")).to.equal(t.event.context); - expect(mainServiceInfoConfigsController.showSavePopup.calledOnce).to.equal(false); - } else { - expect(mainServiceInfoConfigsController.showSavePopup.calledWith(null, t.event)).to.equal(true); - } - }); - }); - - }); - describe("#manageConfigurationGroup", function () { beforeEach(function () { sinon.stub(mainServiceInfoConfigsController, "manageConfigurationGroups", Em.K); @@ -647,7 +588,7 @@ describe("App.MainServiceInfoConfigsController", function () { it('values should be parsed', function () { mainServiceInfoConfigsController.set('stepConfigs', sc); mainServiceInfoConfigsController.doPUTClusterConfigurationSites([]); - expect(mainServiceInfoConfigsController.get('stepConfigs')[0].get('configs').mapProperty('value').uniq()).to.eql(['1024']); + expect(mainServiceInfoConfigsController.get('stepConfigs')[0].get('configs').mapProperty('value').uniq()).to.eql(['1024m']); }); it('values should not be parsed', function () { mainServiceInfoConfigsController.set('stepConfigs', scExc); http://git-wip-us.apache.org/repos/asf/ambari/blob/9e2a81d6/ambari-web/test/controllers/wizard/step7_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js index b550933..7ea1a3b 100644 --- a/ambari-web/test/controllers/wizard/step7_test.js +++ b/ambari-web/test/controllers/wizard/step7_test.js @@ -323,10 +323,12 @@ describe('App.InstallerStep7Controller', function () { installerStep7Controller.reopen({ content: {services: []}, wizardController: Em.Object.create({ - getDBProperty: function () { - return [ - {component: 'GANGLIA_SERVER', hostName: 'h1'} - ]; + + hosts: {'h1': {name: 'host1', id: 'h1'}}, + masterComponentHosts: [{component: 'GANGLIA_SERVER', host_id: 'h1'}], + + getDBProperty: function (k) { + return this.get(k); } }) }); @@ -335,14 +337,14 @@ describe('App.InstallerStep7Controller', function () { it('shouldn\'t do nothing if Ganglia and Storm are installed', function () { var installedServiceNames = ['GANGLIA', 'STORM'], configs = [ - {name: 'nimbus.childopts', value: '.jar=host=', defaultValue: ''}, - {name: 'supervisor.childopts', value: '.jar=host=', defaultValue: ''}, - {name: 'worker.childopts', value: '.jar=host=', defaultValue: ''} + {name: 'nimbus.childopts', value: '.jar=host=host2', defaultValue: ''}, + {name: 'supervisor.childopts', value: '.jar=host=host2', defaultValue: ''}, + {name: 'worker.childopts', value: '.jar=host=host2', defaultValue: ''} ], expected = [ - {name: 'nimbus.childopts', value: '.jar=host=', defaultValue: ''}, - {name: 'supervisor.childopts', value: '.jar=host=', defaultValue: ''}, - {name: 'worker.childopts', value: '.jar=host=', defaultValue: ''} + {name: 'nimbus.childopts', value: '.jar=host=host2', defaultValue: ''}, + {name: 'supervisor.childopts', value: '.jar=host=host2', defaultValue: ''}, + {name: 'worker.childopts', value: '.jar=host=host2', defaultValue: ''} ]; installerStep7Controller.reopen({installedServiceNames: installedServiceNames}); installerStep7Controller.resolveStormConfigs(configs); @@ -352,14 +354,14 @@ describe('App.InstallerStep7Controller', function () { it('shouldn\'t do nothing if Ganglia is in allSelectedServiceNames', function () { var allSelectedServiceNames = ['GANGLIA'], configs = [ - {name: 'nimbus.childopts', value: '.jar=host=', defaultValue: ''}, - {name: 'supervisor.childopts', value: '.jar=host=', defaultValue: ''}, - {name: 'worker.childopts', value: '.jar=host=', defaultValue: ''} + {name: 'nimbus.childopts', value: '.jar=host=host2', defaultValue: ''}, + {name: 'supervisor.childopts', value: '.jar=host=host2', defaultValue: ''}, + {name: 'worker.childopts', value: '.jar=host=host2', defaultValue: ''} ], expected = [ - {name: 'nimbus.childopts', value: 'h1', defaultValue: 'h1', forceUpdate: true}, - {name: 'supervisor.childopts', value: 'h1', defaultValue: 'h1', forceUpdate: true}, - {name: 'worker.childopts', value: 'h1', defaultValue: 'h1', forceUpdate: true} + {name: 'nimbus.childopts', value: '.jar=host=host1', defaultValue: '.jar=host=host1', forceUpdate: true}, + {name: 'supervisor.childopts', value: '.jar=host=host1', defaultValue: '.jar=host=host1', forceUpdate: true}, + {name: 'worker.childopts', value: '.jar=host=host1', defaultValue: '.jar=host=host1', forceUpdate: true} ]; installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames}); installerStep7Controller.resolveStormConfigs(configs); @@ -371,14 +373,14 @@ describe('App.InstallerStep7Controller', function () { it('shouldn\'t do nothing if Ganglia is in installedServiceNames (2)', function () { var installedServiceNames = ['GANGLIA'], configs = [ - {name: 'nimbus.childopts', value: '.jar=host=', defaultValue: ''}, - {name: 'supervisor.childopts', value: '.jar=host=', defaultValue: ''}, - {name: 'worker.childopts', value: '.jar=host=', defaultValue: ''} + {name: 'nimbus.childopts', value: '.jar=host=host2', defaultValue: ''}, + {name: 'supervisor.childopts', value: '.jar=host=host2', defaultValue: ''}, + {name: 'worker.childopts', value: '.jar=host=host2', defaultValue: ''} ], expected = [ - {name: 'nimbus.childopts', value: 'h1', defaultValue: 'h1', forceUpdate: true}, - {name: 'supervisor.childopts', value: 'h1', defaultValue: 'h1', forceUpdate: true}, - {name: 'worker.childopts', value: 'h1', defaultValue: 'h1', forceUpdate: true} + {name: 'nimbus.childopts', value: '.jar=host=host1', defaultValue: '.jar=host=host1', forceUpdate: true}, + {name: 'supervisor.childopts', value: '.jar=host=host1', defaultValue: '.jar=host=host1', forceUpdate: true}, + {name: 'worker.childopts', value: '.jar=host=host1', defaultValue: '.jar=host=host1', forceUpdate: true} ]; installerStep7Controller.reopen({installedServiceNames: installedServiceNames}); installerStep7Controller.resolveStormConfigs(configs); http://git-wip-us.apache.org/repos/asf/ambari/blob/9e2a81d6/ambari-web/test/models/run_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/run_test.js b/ambari-web/test/models/run_test.js index 0478fb0..2b971e8 100644 --- a/ambari-web/test/models/run_test.js +++ b/ambari-web/test/models/run_test.js @@ -137,16 +137,6 @@ describe('App.Run', function () { }); }); - describe('#lastUpdateTimeFormatted', function () { - it('should form date from lastUpdateTime', function () { - run.setProperties({ - elapsedTime: 1000, - startTime: 100000000000 - }); - expect(run.get('lastUpdateTimeFormatted')).to.equal('Sat, Mar 03, 1973 09:46'); - }); - }); - describe('#lastUpdateTimeFormattedShort', function () { it('should form date and time from lastUpdateTime', function () { run.setProperties({ http://git-wip-us.apache.org/repos/asf/ambari/blob/9e2a81d6/ambari-web/test/utils/date_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/date_test.js b/ambari-web/test/utils/date_test.js index 97c7048..9ba7865 100644 --- a/ambari-web/test/utils/date_test.js +++ b/ambari-web/test/utils/date_test.js @@ -60,46 +60,6 @@ describe('date', function () { }); }); - describe('#dateFormat', function() { - describe('Correct timestamps', function(){ - correct_tests.forEach(function(test) { - var testMessage = test.t + ' `showSeconds` ' + !!test.showSeconds + '`showMilliseconds` ' + !!test.showMilliseconds; - it(testMessage, function() { - expect(date.dateFormat(test.t, test.showSeconds, test.showMilliseconds)).to.equal(test.e); - }); - }); - }); - describe('Incorrect timestamps', function() { - incorrect_tests.forEach(function(test) { - it(test.t, function() { - expect(date.dateFormat(test.t)).to.equal(test.t); - }); - }); - }); - }); - - describe('#dateFormatShort', function() { - describe('Correct timestamps', function() { - correct_tests.forEach(function(test) { - it(test.t, function() { - expect(date.dateFormatShort(test.t)).to.equal(test.e2); - }); - }); - }); - it('Today timestamp', function() { - var now = new Date(); - var then = new Date(now.getFullYear(),now.getUTCMonth(),now.getUTCDate(),0,0,0); - expect(date.dateFormatShort(then.getTime() + 10*3600*1000)).to.contain('Today 10:00:00'); - }); - describe('Incorrect timestamps', function() { - incorrect_tests.forEach(function(test) { - it(test.t, function() { - expect(date.dateFormatShort(test.t)).to.equal(test.t); - }); - }); - }); - }); - describe('#startTime()', function() { var today = new Date(); var tests = [