AMBARI-6893 Fix UI unit tests. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6966fb9a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6966fb9a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6966fb9a Branch: refs/heads/branch-alerts-dev Commit: 6966fb9a444dffb5eeda4ba47f6d22a87a169f50 Parents: f9c8bd9 Author: atkach <atk...@hortonworks.com> Authored: Mon Aug 18 18:08:51 2014 +0300 Committer: Jonathan Hurley <jhur...@hortonworks.com> Committed: Mon Aug 18 12:39:08 2014 -0400 ---------------------------------------------------------------------- ambari-web/app/utils/config.js | 2 +- .../main/dashboard/widgets/namenode_cpu.js | 6 ++-- ambari-web/test/utils/config_test.js | 2 +- .../main/dashboard/widgets/namenode_cpu_test.js | 32 +++++++------------- 4 files changed, 16 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/6966fb9a/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index b18bff6..f576f38 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -106,7 +106,7 @@ App.config = Em.Object.create({ * @method getConfigTagFromFileName **/ getConfigTagFromFileName: function(fileName) { - return fileName.endsWith('.xml') ? fileName.slice(0,-4) : filename; + return fileName.endsWith('.xml') ? fileName.slice(0,-4) : fileName; }, setPreDefinedServiceConfigs: function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/6966fb9a/ambari-web/app/views/main/dashboard/widgets/namenode_cpu.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets/namenode_cpu.js b/ambari-web/app/views/main/dashboard/widgets/namenode_cpu.js index 6fca69e..cd3b7f8 100644 --- a/ambari-web/app/views/main/dashboard/widgets/namenode_cpu.js +++ b/ambari-web/app/views/main/dashboard/widgets/namenode_cpu.js @@ -78,12 +78,12 @@ App.NameNodeCpuPieChartView = App.PieChartDashboardWidgetView.extend({ }, calcIsPieExists: function() { - return (this.get('cpuWio') != null); + return (!Em.isNone(this.get('cpuWio'))); }, - calcDataForPieChart: function() { + calcDataForPieChart: function () { var value = this.get('cpuWio'); - value = value >= 100 ? 100: value; + value = value >= 100 ? 100 : value; var percent = (value + 0).toFixed(1); var percent_precise = (value + 0).toFixed(2); return [ percent, percent_precise]; http://git-wip-us.apache.org/repos/asf/ambari/blob/6966fb9a/ambari-web/test/utils/config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js index 9a9bd1e..451f748 100644 --- a/ambari-web/test/utils/config_test.js +++ b/ambari-web/test/utils/config_test.js @@ -337,7 +337,7 @@ describe('App.config', function () { App.config.addAdvancedConfigs(this.storedConfigs, modelSetup.setupAdvancedConfigsObject(), 'ZOOKEEPER'); var property = this.storedConfigs.findProperty('name', 'custom.zoo.cfg'); expect(property).to.be.ok; - expect(property.category).to.eql('Advanced'); + expect(property.category).to.eql('Advanced zoo.cfg'); }); it('`capacity-scheduler.xml` property with name `content` should have `displayType` `multiLine`', function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/6966fb9a/ambari-web/test/views/main/dashboard/widgets/namenode_cpu_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/dashboard/widgets/namenode_cpu_test.js b/ambari-web/test/views/main/dashboard/widgets/namenode_cpu_test.js index 7d1ffec..347d5d0 100644 --- a/ambari-web/test/views/main/dashboard/widgets/namenode_cpu_test.js +++ b/ambari-web/test/views/main/dashboard/widgets/namenode_cpu_test.js @@ -43,21 +43,17 @@ describe('App.NameNodeCpuPieChartView', function() { describe('#calcIsPieExists', function() { var tests = [ { - model: Em.Object.create({ - used: 1 - }), + cpuWio: 1, e: true, m: 'Exists' }, { - model: Em.Object.create({ - used: 0 - }), - e: true, - m: 'Exists' + cpuWio: null, + e: false, + m: 'Not exists' }, { - model: Em.Object.create({}), + cpuWio: undefined, e: false, m: 'Not exists' } @@ -65,32 +61,26 @@ describe('App.NameNodeCpuPieChartView', function() { tests.forEach(function(test) { it(test.m, function() { - nameNodeCpuPieChartView.set('model', test.model); + nameNodeCpuPieChartView.set('cpuWio', test.cpuWio); expect(nameNodeCpuPieChartView.calcIsPieExists()).to.equal(test.e); }); }); }); - describe('calcDataForPieChart', function() { + describe('calcDataForPieChart', function () { var tests = [ { - model: Em.Object.create({ - used: 0 - }), + cpuWio: 0, e: ['0.0', '0.00'], m: 'Nothing is used' }, { - model: Em.Object.create({ - used: 100 - }), + cpuWio: 100, e: ['100.0', '100.00'], m: 'All is used' }, { - model: Em.Object.create({ - used: 50 - }), + cpuWio: 50, e: ['50.0', '50.00'], m: 'Half is used' } @@ -98,7 +88,7 @@ describe('App.NameNodeCpuPieChartView', function() { tests.forEach(function(test) { it(test.m, function() { - nameNodeCpuPieChartView.set('model', test.model); + nameNodeCpuPieChartView.set('cpuWio', test.cpuWio); expect(nameNodeCpuPieChartView.calcDataForPieChart()).to.eql(test.e); }); });