http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/controllers/wizard/step9_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step9_test.js b/ambari-web/test/controllers/wizard/step9_test.js index 03c072f..70365bb 100644 --- a/ambari-web/test/controllers/wizard/step9_test.js +++ b/ambari-web/test/controllers/wizard/step9_test.js @@ -342,7 +342,7 @@ describe('App.InstallerStep9Controller', function () { }); }); - var hosts_for_load_and_render = { + var hostsForLoadAndRender = { 'host1': { message: 'message1', status: 'unknown', @@ -387,23 +387,23 @@ describe('App.InstallerStep9Controller', function () { describe('#loadHosts', function () { beforeEach(function() { - c.reopen({content: {hosts: hosts_for_load_and_render}}); + c.reopen({content: {hosts: hostsForLoadAndRender}}); c.loadHosts(); }); it('Only REGISTERED hosts', function () { - var loaded_hosts = c.get('hosts'); - expect(loaded_hosts.length).to.equal(2); + var loadedHosts = c.get('hosts'); + expect(loadedHosts.length).to.equal(2); }); it('All hosts have progress 0', function () { - var loaded_hosts = c.get('hosts'); - expect(loaded_hosts.everyProperty('progress', 0)).to.equal(true); + var loadedHosts = c.get('hosts'); + expect(loadedHosts.everyProperty('progress', 0)).to.equal(true); }); it('All host don\'t have logTasks', function () { - var loaded_hosts = c.get('hosts'); - expect(loaded_hosts.everyProperty('logTasks.length', 0)).to.equal(true); + var loadedHosts = c.get('hosts'); + expect(loadedHosts.everyProperty('logTasks.length', 0)).to.equal(true); }); }); @@ -589,7 +589,7 @@ describe('App.InstallerStep9Controller', function () { describe('#launchStartServices', function () { beforeEach(function() { sinon.stub(App, 'get', function(k) { - if (k === 'components.slaves') + if (k === 'components.slaves') { return ["TASKTRACKER", "DATANODE", "JOURNALNODE", "ZKFC", "APP_TIMELINE_SERVER", @@ -598,6 +598,7 @@ describe('App.InstallerStep9Controller', function () { "HBASE_REGIONSERVER", "SUPERVISOR", "FLUME_HANDLER"]; + } return true; }); }); @@ -870,8 +871,9 @@ describe('App.InstallerStep9Controller', function () { beforeEach(function() { sinon.stub(App, 'get', function(k) { - if (k === 'components.slaves') + if (k === 'components.slaves') { return ["TASKTRACKER", "DATANODE", "JOURNALNODE", "ZKFC", "APP_TIMELINE_SERVER", "NODEMANAGER", "GANGLIA_MONITOR", "HBASE_REGIONSERVER", "SUPERVISOR", "FLUME_HANDLER"]; + } return Em.get(App, k); }); }); @@ -964,7 +966,7 @@ describe('App.InstallerStep9Controller', function () { tests.forEach(function (test) { it(test.m, function () { c.onInProgressPerHost(test.actions, test.host); - expect(test.host.message == test.e.message).to.equal(test.e.b); + expect(test.host.message === test.e.message).to.equal(test.e.b); }); }); }); @@ -1163,8 +1165,9 @@ describe('App.InstallerStep9Controller', function () { beforeEach(function() { sinon.stub(App, 'get', function(k) { - if (k === 'components.slaves') + if (k === 'components.slaves') { return ["TASKTRACKER", "DATANODE", "JOURNALNODE", "ZKFC", "APP_TIMELINE_SERVER", "NODEMANAGER", "GANGLIA_MONITOR", "HBASE_REGIONSERVER", "SUPERVISOR", "FLUME_HANDLER"]; + } return Em.get(App, k); }); });
http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/controllers/wizard_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js index 08d9d89..8ffa697 100644 --- a/ambari-web/test/controllers/wizard_test.js +++ b/ambari-web/test/controllers/wizard_test.js @@ -22,41 +22,41 @@ require('controllers/wizard'); var c; +function getSteps(start, count) { + var steps = []; + for (var j = start; j <= count; j++) { + steps.push(Em.Object.create({step: j, value: false})); + } + return steps; +} + describe('App.WizardController', function () { var wizardController = App.WizardController.create({}); var totalSteps = 11; - var ruller = []; - for(var i = 0; i < totalSteps; i++) { - ruller.push(i); - } - + var ruller = d3.range(0, totalSteps); + var i; beforeEach(function () { c = App.WizardController.create({}); }); - describe('#setLowerStepsDisable', function() { - for(var i = 1; i < totalSteps; i++) { - var indx = i; - var steps = []; - for(var j = 1; j <= indx; j++) { - steps.push(Em.Object.create({step:j,value:false})); - } - wizardController.set('isStepDisabled', steps); - for(j = 1; j <= indx; j++) { - it('Steps: ' + i + ' | Disabled: ' + (j-1), function() { - wizardController.setLowerStepsDisable(j); - expect(wizardController.get('isStepDisabled').filterProperty('value', true).length).to.equal(j-1); - }); - } - } + describe('#setLowerStepsDisable', function () { + var steps = getSteps(1, 10); + wizardController.set('isStepDisabled', steps); + steps.forEach(function (step) { + var index = step.get('step'); + it('Steps: 10 | Disabled: ' + (index - 1), function () { + wizardController.setLowerStepsDisable(index); + expect(wizardController.get('isStepDisabled').filterProperty('value', true).length).to.be.equal(index - 1); + }); + }); }); // isStep0 ... isStep10 tests App.WizardController1 = App.WizardController.extend({currentStep:''}); var tests = []; - for (var i = 0; i < totalSteps; i++) { + for (i = 0; i < totalSteps; i++) { var n = ruller.slice(0); n.splice(i, 1); tests.push({i: i, n: n}); @@ -65,11 +65,13 @@ describe('App.WizardController', function () { describe('isStep' + test.i, function () { var w = App.WizardController1.create(); w.set('currentStep', test.i); - it('Current Step is ' + test.i + ', so isStep' + test.i + ' is TRUE', function () { + + it('Current Step is {0}, so isStep{1} is TRUE'.format(test.i, test.i), function () { expect(w.get('isStep' + test.i)).to.equal(true); }); + test.n.forEach(function (indx) { - it('Current Step is ' + test.i + ', so isStep' + indx + ' is FALSE', function () { + it('Current Step is {0}, so isStep{1} is FALSE'.format(test.i, indx), function () { expect(w.get('isStep' + indx)).to.equal(false); }); }); @@ -79,14 +81,11 @@ describe('App.WizardController', function () { describe('#gotoStep', function() { var w = App.WizardController1.create(); - var steps = []; - for(var j = 0; j < totalSteps; j++) { - steps.push(Em.Object.create({step:j,value:false})); - } + var steps = getSteps(0, totalSteps - 1); steps.forEach(function(step, index) { step.set('value', true); w.set('isStepDisabled', steps); - it('step ' + index + ' is disabled, so gotoStep('+index+') is not possible', function() { + it('step {0} is disabled, so gotoStep({1}) is not possible'.format(index, index), function() { expect(w.gotoStep(index)).to.equal(false); }); }); @@ -284,8 +283,7 @@ describe('App.WizardController', function () { }); describe('#finishLoading', function () { - var callback = sinon.spy(), - stepController = App.get('router.wizardStep3Controller'), + var stepController = App.get('router.wizardStep3Controller'), cases = [ { requestId: null, @@ -691,11 +689,6 @@ describe('App.WizardController', function () { App.ajax.send.restore(); }); it('should call callbeck with data', function () { - var jsonData = { - Requests: { - id: 1 - } - }; wizardController.set('content', Em.Object.create({ cluster: { oldRequestsId: '1' @@ -846,7 +839,7 @@ describe('App.WizardController', function () { sinon.stub(App.MainAdminServiceAccountsController,'create').returns({ loadUsers: function() {}, get: function(type) { - if (type == 'dataIsLoaded') { + if (type === 'dataIsLoaded') { return true; } return Em.Object.create({ @@ -1502,9 +1495,7 @@ describe('App.WizardController', function () { }); sinon.stub(App.themesMapper, 'generateAdvancedTabs').returns(true); sinon.stub(App.config, 'loadConfigsFromStack').returns({ - done: function(callback) { - callback(); - } + done: Em.clb }); sinon.stub(App.StackService, 'find').returns(Em.A([ Em.Object.create({ @@ -1521,16 +1512,16 @@ describe('App.WizardController', function () { App.themesMapper.generateAdvancedTabs.restore(); wizardController.loadConfigThemeForServices.restore(); }); - it('Should load config themes', function() { + it('Should load config themes', function(done) { this.stub.returns(true); - wizardController.loadConfigThemes().then(function(data) { - expect().to.be.undefined; + wizardController.loadConfigThemes().then(function() { + done(); }); }); - it('Should load config themes (2)', function() { + it('Should load config themes (2)', function(done) { this.stub.returns(false); - wizardController.loadConfigThemes().then(function(data) { - expect().to.be.undefined; + wizardController.loadConfigThemes().then(function() { + done(); }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/data/HDP2.2/site_properties_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/data/HDP2.2/site_properties_test.js b/ambari-web/test/data/HDP2.2/site_properties_test.js index a5e0e18..14599b3 100644 --- a/ambari-web/test/data/HDP2.2/site_properties_test.js +++ b/ambari-web/test/data/HDP2.2/site_properties_test.js @@ -16,7 +16,6 @@ * limitations under the License. */ -var App = require('app'); require('utils/helper'); require('data/HDP2/gluster_fs_properties'); var siteProperties = require('data/HDP2.2/site_properties').configProperties; @@ -26,7 +25,7 @@ describe('hdp2SiteProperties', function () { * @stackProperties: All the properties that are derived from stack definition */ var stackProperties = siteProperties.filter(function(item){ - return !(item.isRequiredByAgent === false || item.category === 'Ambari Principals') + return !(item.isRequiredByAgent === false || item.category === 'Ambari Principals') }); stackProperties.forEach(function(siteProperty){ @@ -43,7 +42,7 @@ describe('hdp2SiteProperties', function () { * showLabel * unit */ - describe('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Stack driven attributes should be undefined ', function () { + describe('Check attributes of "{0}/{1}". Stack driven attributes should be undefined '.format(siteProperty.filename, siteProperty.name), function () { ['isVisible', 'value', 'recommendedValue', 'description', 'isReconfigurable', 'isRequired', 'displayName', 'showLabel', 'unit'].forEach(function (p) { it(p, function () { expect(siteProperty[p]).to.not.exist; @@ -55,7 +54,7 @@ describe('hdp2SiteProperties', function () { * displayTypes <code>supportTextConnection<code> and <code>radio button<code> * can be used as exception. Other displayTypes values should be used in stack definition */ - it('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Display type value ' + siteProperty.displayType + ' should be described in stack ', function () { + it('Check attributes of "{0}/{1}". Display type value {2} should be described in stack '.format(siteProperty.filename, siteProperty.name, siteProperty.displayType), function () { expect(siteProperty.displayType).to.match(/undefined|supportTextConnection|radio button/); }); @@ -64,7 +63,7 @@ describe('hdp2SiteProperties', function () { * name * filename */ - describe('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Attributes that uniquely represent a property should be defined ', function () { + describe('Check primary attributes of "{0}/{1}". Attributes that uniquely represent a property should be defined '.format(siteProperty.filename, siteProperty.name), function () { it('name', function () { expect(siteProperty.name).to.not.equal(undefined); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/data/HDP2.3/site_properties_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/data/HDP2.3/site_properties_test.js b/ambari-web/test/data/HDP2.3/site_properties_test.js index b94e0b2..6ce9c17 100644 --- a/ambari-web/test/data/HDP2.3/site_properties_test.js +++ b/ambari-web/test/data/HDP2.3/site_properties_test.js @@ -16,7 +16,6 @@ * limitations under the License. */ -var App = require('app'); require('utils/helper'); require('data/HDP2/gluster_fs_properties'); var siteProperties = require('data/HDP2.3/site_properties').configProperties; @@ -26,7 +25,7 @@ describe('hdp2SiteProperties', function () { * @stackProperties: All the properties that are derived from stack definition */ var stackProperties = siteProperties.filter(function(item){ - return !(item.isRequiredByAgent === false || item.category === 'Ambari Principals') + return !(item.isRequiredByAgent === false || item.category === 'Ambari Principals') }); stackProperties.forEach(function(siteProperty){ @@ -43,7 +42,7 @@ describe('hdp2SiteProperties', function () { * showLabel * unit */ - describe('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Stack driven attributes should be undefined ', function () { + describe('Check attributes of "{0}/{1}". Stack driven attributes should be undefined '.format(siteProperty.filename, siteProperty.name), function () { ['isVisible', 'value', 'recommendedValue', 'description', 'isReconfigurable', 'isRequired', 'displayName', 'showLabel', 'unit'].forEach(function (p) { it(p, function () { expect(siteProperty[p]).to.not.exist; @@ -56,7 +55,7 @@ describe('hdp2SiteProperties', function () { * displayTypes <code>supportTextConnection<code> and <code>radio button<code> * can be used as exception. Other displayTypes values should be used in stack definition */ - it('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Display type value ' + siteProperty.displayType + ' should be described in stack ', function () { + it('Check attributes of "{0}/{1}". Display type value {2} should be described in stack '.format(siteProperty.filename, siteProperty.name, siteProperty.displayType), function () { expect(siteProperty.displayType).to.match(/undefined|supportTextConnection|radio button/); }); @@ -65,7 +64,7 @@ describe('hdp2SiteProperties', function () { * name * filename */ - describe('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Attributes that uniquely represent a property should be defined ', function () { + describe('Check primary attributes of "{0}/{1}". Attributes that uniquely represent a property should be defined '.format(siteProperty.filename, siteProperty.name), function () { it('name', function () { expect(siteProperty.name).to.not.equal(undefined); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/data/HDP2/secure_mapping_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/data/HDP2/secure_mapping_test.js b/ambari-web/test/data/HDP2/secure_mapping_test.js index e7082f2..766243f 100644 --- a/ambari-web/test/data/HDP2/secure_mapping_test.js +++ b/ambari-web/test/data/HDP2/secure_mapping_test.js @@ -16,7 +16,6 @@ * limitations under the License. */ -var App = require('app'); require('utils/helper'); var mappedHdp2Properties = require('data/HDP2/secure_mapping'); @@ -24,12 +23,12 @@ describe('hdp2SiteMapping', function () { // All mapped properties should have value of string type mappedHdp2Properties.forEach(function(mappedProperty){ - it('Value of "' + mappedProperty.name + '"' + ' should be string', function () { + it('Value of "{0}" should be string'.format(mappedProperty.name), function () { expect(mappedProperty.value).to.be.a('string'); }); }); mappedHdp2Properties.forEach(function(mappedProperty){ - it('Value of "' + mappedProperty.name + '"' + ' should have serviceName and filename attribute', function () { + it('Value of "{0}" should have serviceName and filename attribute'.format(mappedProperty.name), function () { expect(mappedProperty).to.have.property('serviceName'); expect(mappedProperty).to.have.property('filename'); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/data/HDP2/site_properties_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/data/HDP2/site_properties_test.js b/ambari-web/test/data/HDP2/site_properties_test.js index 26be9c3..c8b7bbc 100644 --- a/ambari-web/test/data/HDP2/site_properties_test.js +++ b/ambari-web/test/data/HDP2/site_properties_test.js @@ -16,7 +16,6 @@ * limitations under the License. */ -var App = require('app'); require('utils/helper'); require('data/HDP2/gluster_fs_properties'); var siteProperties = require('data/HDP2/site_properties').configProperties; @@ -26,7 +25,7 @@ describe('hdp2SiteProperties', function () { * @stackProperties: All the properties that are derived from stack definition */ var stackProperties = siteProperties.filter(function(item){ - return !(item.isRequiredByAgent === false || item.category === 'Ambari Principals') + return !(item.isRequiredByAgent === false || item.category === 'Ambari Principals') }); stackProperties.forEach(function(siteProperty){ @@ -43,7 +42,7 @@ describe('hdp2SiteProperties', function () { * showLabel * unit */ - describe('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Stack driven attributes should be undefined ', function () { + describe('Check attributes of "{0}/{1}". Stack driven attributes should be undefined '.format(siteProperty.filename, siteProperty.name), function () { ['isVisible', 'value', 'recommendedValue', 'description', 'isReconfigurable', 'isRequired', 'displayName', 'showLabel', 'unit'].forEach(function (p) { it(p, function () { expect(siteProperty[p]).to.not.exist; @@ -55,7 +54,7 @@ describe('hdp2SiteProperties', function () { * displayTypes <code>supportTextConnection<code> and <code>radio button<code> * can be used as exception. Other displayTypes values should be used in stack definition */ - it('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Display type value ' + siteProperty.displayType + ' should be described in stack ', function () { + it('Check attributes of "{0}/{1}". Display type value {2} should be described in stack '.format(siteProperty.filename, siteProperty.name, siteProperty.displayType), function () { expect(siteProperty.displayType).to.match(/undefined|supportTextConnection|radio button/); }); @@ -64,7 +63,7 @@ describe('hdp2SiteProperties', function () { * name * filename */ - describe('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Attributes that uniquely represent a property should be defined ', function () { + describe('Check primary attributes of "{0}/{1}". Attributes that uniquely represent a property should be defined '.format(siteProperty.filename, siteProperty.name), function () { it('name', function () { expect(siteProperty.name).to.not.equal(undefined); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/init_computed_aliases.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/init_computed_aliases.js b/ambari-web/test/init_computed_aliases.js index 62d0842..57e0861 100644 --- a/ambari-web/test/init_computed_aliases.js +++ b/ambari-web/test/init_computed_aliases.js @@ -40,10 +40,9 @@ App.TestAliases = { /** * Stub <code>get</code> for <code>App</code> or <code>self</code> * - * @param {Ember.Object} self * @returns {App.TestAliases} */ - smartStubGet: function (self) { + smartStubGet: function () { var args = [].slice.call(arguments); if (args.length === 3) { return this._stubOneKey.apply(this, args); @@ -156,7 +155,7 @@ App.TestAliases = { for (var y = 0; y < allCombos; y++) { var combo = {}; for (var x = 0; x < n; x++) { - combo[dependentKeys[x]] = !!((y >> x) & 1); + combo[dependentKeys[x]] = !!(y >> x & 1); } result.push(combo); } http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/init_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/init_test.js b/ambari-web/test/init_test.js index 8b1cfab..df64cbe 100644 --- a/ambari-web/test/init_test.js +++ b/ambari-web/test/init_test.js @@ -29,10 +29,10 @@ if (!Function.prototype.bind) { throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); } - var aArgs = Array.prototype.slice.call(arguments, 1), + var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, - fNOP = function() {}, - fBound = function() { + fNOP = function() {}, + fBound = function() { return fToBind.apply(this instanceof fNOP ? this : oThis, http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/login_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/login_test.js b/ambari-web/test/login_test.js index 1975b2d..b72ab94 100644 --- a/ambari-web/test/login_test.js +++ b/ambari-web/test/login_test.js @@ -16,29 +16,8 @@ * limitations under the License. */ -var App = require('app'); - require('controllers/login_controller'); describe('App.LoginController', function () { - - var loginController = App.LoginController.create(); - - describe('#validateCredentials()', function () { - /* - it('should return undefined if no username is present', function () { - loginController.set('loginName', ''); - expect(loginController.validateCredentials()).to.equal(undefined); - }) - it('should return undefined if no password is present', function () { - loginController.set('password', ''); - expect(loginController.validateCredentials()).to.equal(undefined); - }) - it('should return the user object with the specified username and password (dummy until actual integration)', function () { - loginController.set('loginName', 'admin'); - loginController.set('password', 'admin'); - expect(loginController.validateCredentials().get('loginName'), 'admin'); - }) - */ - }) + describe('#validateCredentials()', function () {}); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mappers/alert_definitions_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/alert_definitions_mapper_test.js b/ambari-web/test/mappers/alert_definitions_mapper_test.js index 180e728..6626187 100644 --- a/ambari-web/test/mappers/alert_definitions_mapper_test.js +++ b/ambari-web/test/mappers/alert_definitions_mapper_test.js @@ -201,7 +201,7 @@ describe('App.alertDefinitionsMapper', function () { }); sinon.stub(App.router, 'get', function() {return false;}); - App.cache['previousAlertGroupsMap'] = {}; + App.cache.previousAlertGroupsMap = {}; sinon.stub(App.alertDefinitionsMapper, 'setMetricsSourcePropertyLists', Em.K); sinon.stub(App.alertDefinitionsMapper, 'setAlertDefinitionsRawSourceData', Em.K); @@ -224,7 +224,7 @@ describe('App.alertDefinitionsMapper', function () { App.alertDefinitionsMapper.deleteRecord.restore(); App.router.get.restore(); - App.cache['previousAlertGroupsMap'] = {}; + App.cache.previousAlertGroupsMap = {}; App.alertDefinitionsMapper.setMetricsSourcePropertyLists.restore(); App.alertDefinitionsMapper.setAlertDefinitionsRawSourceData.restore(); @@ -403,7 +403,7 @@ describe('App.alertDefinitionsMapper', function () { it('should set groups from App.cache.previousAlertGroupsMap', function () { - App.cache['previousAlertGroupsMap'] = { + App.cache.previousAlertGroupsMap = { 1: [5,1], 2: [4,3], 3: [3,2], http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mappers/alert_groups_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/alert_groups_mapper_test.js b/ambari-web/test/mappers/alert_groups_mapper_test.js index eb83759..9480e3d 100644 --- a/ambari-web/test/mappers/alert_groups_mapper_test.js +++ b/ambari-web/test/mappers/alert_groups_mapper_test.js @@ -93,7 +93,7 @@ describe('App.alertGroupsMapper', function () { }); App.alertGroupsMapper.set('model', {}); - App.cache['previousAlertGroupsMap'] = {}; + App.cache.previousAlertGroupsMap = {}; }); @@ -102,10 +102,11 @@ describe('App.alertGroupsMapper', function () { App.store.commit.restore(); App.store.loadMany.restore(); App.alertGroupsMapper.set('model', App.AlertGroup); - App.cache['previousAlertGroupsMap'] = {}; + App.cache.previousAlertGroupsMap = {}; }); + /*eslint-disable mocha-cleanup/asserts-limit */ it('should parse alert groups', function() { var expected = [ @@ -126,12 +127,10 @@ describe('App.alertGroupsMapper', function () { ]; App.alertGroupsMapper.map(json); - var mapped = App.alertGroupsMapper.get('model.content'); - testHelpers.nestedExpect(expected, mapped); - }); + /*eslint-enable mocha-cleanup/asserts-limit */ it('should set App.cache.previousAlertGroupsMap', function () { @@ -149,7 +148,7 @@ describe('App.alertGroupsMapper', function () { App.alertGroupsMapper.map(json); - expect(App.cache['previousAlertGroupsMap']).to.eql(expected); + expect(App.cache.previousAlertGroupsMap).to.eql(expected); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mappers/alert_instances_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/alert_instances_mapper_test.js b/ambari-web/test/mappers/alert_instances_mapper_test.js index 6ea0086..efa5531 100644 --- a/ambari-web/test/mappers/alert_instances_mapper_test.js +++ b/ambari-web/test/mappers/alert_instances_mapper_test.js @@ -21,13 +21,7 @@ require('mappers/alert_instances_mapper'); describe('App.alertInstanceMapper', function () { - var alertInstances = [ - {id: 1}, - {id: 2}, - {id: 3}, - {id: 4} - ], - json = { + var json = { "items": [ { "Alert": { http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mappers/hosts_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/hosts_mapper_test.js b/ambari-web/test/mappers/hosts_mapper_test.js index 5e5c293..1d7d80a 100644 --- a/ambari-web/test/mappers/hosts_mapper_test.js +++ b/ambari-web/test/mappers/hosts_mapper_test.js @@ -16,7 +16,6 @@ * limitations under the License. */ -var Ember = require('ember'); var App = require('app'); require('models/host'); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mappers/server_data_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/server_data_mapper_test.js b/ambari-web/test/mappers/server_data_mapper_test.js index 9c4adbb..d144afa 100644 --- a/ambari-web/test/mappers/server_data_mapper_test.js +++ b/ambari-web/test/mappers/server_data_mapper_test.js @@ -16,7 +16,6 @@ * limitations under the License. */ -var Ember = require('ember'); var App = require('app'); var mapper; @@ -24,7 +23,7 @@ require('mappers/server_data_mapper'); describe('App.QuickDataMapper', function () { - var test_json = { + var testJson = { a1: { b1: { c1: 'val1' @@ -62,7 +61,7 @@ describe('App.QuickDataMapper', function () { ]; tests.forEach(function(test) { it(test.i, function() { - expect(mapper.getJsonProperty(test_json, test.i)).to.equal(test.e); + expect(mapper.getJsonProperty(testJson, test.i)).to.equal(test.e); }); }); }); @@ -82,7 +81,7 @@ describe('App.QuickDataMapper', function () { var result; beforeEach(function () { - result = mapper.parseIt(test_json, config); + result = mapper.parseIt(testJson, config); }); it('Property starts with $', function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mappers/service_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/service_mapper_test.js b/ambari-web/test/mappers/service_mapper_test.js index 270147a..0634f19 100644 --- a/ambari-web/test/mappers/service_mapper_test.js +++ b/ambari-web/test/mappers/service_mapper_test.js @@ -16,7 +16,6 @@ * limitations under the License. */ -var Ember = require('ember'); var App = require('app'); require('utils/helper'); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mappers/stack_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/stack_mapper_test.js b/ambari-web/test/mappers/stack_mapper_test.js index 7b124af..0bc0f3c 100644 --- a/ambari-web/test/mappers/stack_mapper_test.js +++ b/ambari-web/test/mappers/stack_mapper_test.js @@ -16,7 +16,6 @@ * limitations under the License. */ -var Ember = require('ember'); var App = require('app'); require('mappers/server_data_mapper'); require('mappers/stack_mapper'); @@ -27,7 +26,7 @@ require('models/repository'); describe('App.stackMapper', function () { describe("#map", function() { - var test_data = { + var testData = { items: [{ "Versions" : { "active" : true, @@ -261,7 +260,7 @@ describe('App.stackMapper', function () { App.resetDsStoreTypeMap(App.OperatingSystem); App.resetDsStoreTypeMap(App.Stack); sinon.stub(App.store, 'commit', Em.K); - App.stackMapper.map(test_data); + App.stackMapper.map(testData); }); afterEach(function(){ App.store.commit.restore(); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mappers/status_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/status_mapper_test.js b/ambari-web/test/mappers/status_mapper_test.js index 3ca5be9..dce5254 100644 --- a/ambari-web/test/mappers/status_mapper_test.js +++ b/ambari-web/test/mappers/status_mapper_test.js @@ -16,12 +16,4 @@ * limitations under the License. */ -var Ember = require('ember'); -var App = require('app'); - -require('mappers/server_data_mapper'); - -describe('App.statusMapper', function () { - - -}); +describe('App.statusMapper', function () {}); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mappers/users_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/users_mapper_test.js b/ambari-web/test/mappers/users_mapper_test.js index 2ff0cd7..22c2466 100644 --- a/ambari-web/test/mappers/users_mapper_test.js +++ b/ambari-web/test/mappers/users_mapper_test.js @@ -16,7 +16,6 @@ * limitations under the License. */ -var Ember = require('ember'); var App = require('app'); require('mappers/server_data_mapper'); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mixins/common/configs/config_recommendations_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/configs/config_recommendations_test.js b/ambari-web/test/mixins/common/configs/config_recommendations_test.js index ad529b9..3f7d6b1 100644 --- a/ambari-web/test/mixins/common/configs/config_recommendations_test.js +++ b/ambari-web/test/mixins/common/configs/config_recommendations_test.js @@ -19,7 +19,7 @@ var App = require('app'); describe('App.ConfigRecommendations', function() { - var mixinObject = Em.Controller.extend(App.ConfigRecommendations, {}); + var mixinObject = Em.Controller.extend(App.ConfigRecommendations, {}); var instanceObject = mixinObject.create({}); beforeEach(function() { @@ -307,7 +307,7 @@ describe('App.ConfigRecommendations', function() { expect(instanceObject.getRecommendation('p1', 'f1')).to.eql(recommendations[0]); }); - it('get recommendation for default group', function () { + it('get recommendation for default group (2)', function () { expect(instanceObject.getRecommendation('p1', 'f1', 'group1')).to.eql(recommendations[2]); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mixins/common/configs/configs_saver_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/configs/configs_saver_test.js b/ambari-web/test/mixins/common/configs/configs_saver_test.js index 5bf6f26..2156a46 100644 --- a/ambari-web/test/mixins/common/configs/configs_saver_test.js +++ b/ambari-web/test/mixins/common/configs/configs_saver_test.js @@ -19,7 +19,7 @@ var App = require('app'); describe('App.ConfigsSaverMixin', function() { - var mixinObject = Em.Controller.extend(App.ConfigsSaverMixin, {}); + var mixinObject = Em.Controller.extend(App.ConfigsSaverMixin, {}); var instanceObject = mixinObject.create({}); describe('#allowSaveSite()', function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js b/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js index c4bdd23..49865db 100644 --- a/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js +++ b/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js @@ -19,8 +19,7 @@ var App = require('app'); describe('#_overrideConfigIsRequired', function () { - var controller, - instanceObject, + var instanceObject, configs, serviceConfig; http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js b/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js index edfed5f..20f6b76 100644 --- a/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js +++ b/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js @@ -71,6 +71,19 @@ describe('App.KDCCredentialsControllerMixin', function() { describe('#createKDCCredentials', function() { + function createConfig (name, value) { + return App.ServiceConfigProperty.create({ + name: name, + value: value + }); + } + function resolveWith (data) { + return $.Deferred().resolve(data).promise(); + } + function rejectWith (data) { + return $.Deferred().reject(data).promise(); + } + beforeEach(function () { sinon.stub(App, 'get').withArgs('clusterName').returns('testName'); sinon.stub(credentialsUtils, 'createCredentials', function() { @@ -90,18 +103,6 @@ describe('App.KDCCredentialsControllerMixin', function() { credentialsUtils.updateCredentials.restore(); }); - var createConfig = function(name, value) { - return App.ServiceConfigProperty.create({ - name: name, - value: value - }); - }; - var resolveWith = function(data) { - return $.Deferred().resolve(data).promise(); - }; - var rejectWith = function(data) { - return $.Deferred().reject(data).promise(); - }; [ { configs: [ http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mixins/common/serverValidator_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/serverValidator_test.js b/ambari-web/test/mixins/common/serverValidator_test.js index e0fed81..c6d528a 100644 --- a/ambari-web/test/mixins/common/serverValidator_test.js +++ b/ambari-web/test/mixins/common/serverValidator_test.js @@ -33,14 +33,14 @@ describe('App.ServerValidatorMixin', function() { }; var genResponse = function(items) { return { - items: (items.map(function(item) { return genRespItem.apply(undefined, item); })) + items: items.map(function(item) { return genRespItem.apply(undefined, item); }) }; }; var genConfigs = function(configs) { return Em.Object.create({ - configs: (configs.map(function(item) { + configs: configs.map(function(item) { return Em.Object.create({ name: item[0], filename: item[1] }); - })) + }) }); }; var tests = [ http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mixins/common/widget_mixin_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/widget_mixin_test.js b/ambari-web/test/mixins/common/widget_mixin_test.js index 72c7da8..e35f955 100644 --- a/ambari-web/test/mixins/common/widget_mixin_test.js +++ b/ambari-web/test/mixins/common/widget_mixin_test.js @@ -118,7 +118,7 @@ describe('App.WidgetMixin', function () { }); it('HBASE_HBASE_REGIONSERVER', function () { - var HBASE_HBASE_REGIONSERVER = { + var hbaseRegionServer = { "name": "regionserver.Server.percentFilesLocal", "service_name": "HBASE", "component_name": "HBASE_REGIONSERVER", @@ -137,11 +137,11 @@ describe('App.WidgetMixin', function () { } ] }; - expect(JSON.stringify(this.requestData['HBASE_HBASE_REGIONSERVER'])).to.equal(JSON.stringify(HBASE_HBASE_REGIONSERVER)); + expect(JSON.stringify(this.requestData.HBASE_HBASE_REGIONSERVER)).to.equal(JSON.stringify(hbaseRegionServer)); }); it('HBASE_HBASE_REGIONSERVER_c1', function () { - var HBASE_HBASE_REGIONSERVER_c1 = { + var hbaseRegionServerC1 = { "name": "regionserver.Server.percentFilesLocal", "service_name": "HBASE", "component_name": "HBASE_REGIONSERVER", @@ -155,11 +155,11 @@ describe('App.WidgetMixin', function () { } ] }; - expect(JSON.stringify(this.requestData['HBASE_HBASE_REGIONSERVER_c1'])).to.equal(JSON.stringify(HBASE_HBASE_REGIONSERVER_c1)); + expect(JSON.stringify(this.requestData.HBASE_HBASE_REGIONSERVER_c1)).to.equal(JSON.stringify(hbaseRegionServerC1)); }); it('HDFS_DATANODE_c1', function () { - var HDFS_DATANODE_c1 = { + var hdfsDataNodeC1 = { "name": "regionserver.Server.percentFilesLocal", "service_name": "HDFS", "component_name": "DATANODE", @@ -173,7 +173,7 @@ describe('App.WidgetMixin', function () { } ] }; - expect(JSON.stringify(this.requestData['HDFS_DATANODE_c1'])).to.equal(JSON.stringify(HDFS_DATANODE_c1)); + expect(JSON.stringify(this.requestData.HDFS_DATANODE_c1)).to.equal(JSON.stringify(hdfsDataNodeC1)); }); }); @@ -484,29 +484,29 @@ describe('App.WidgetLoadAggregator', function () { result = aggregator.groupRequests(requests); }); - it("result['n1_C1'].subRequests.length", function () { - expect(result['n1_C1'].subRequests.length).to.equal(1); + it("result.n1_C1.subRequests.length", function () { + expect(result.n1_C1.subRequests.length).to.equal(1); }); - it("result['n1_C1'].data.metric_paths.length", function () { - expect(result['n1_C1'].data.metric_paths.length).to.equal(1); + it("result.n1_C1.data.metric_paths.length", function () { + expect(result.n1_C1.data.metric_paths.length).to.equal(1); }); - it("result['n1_C1_graph'].subRequests.length", function () { - expect(result['n1_C1_graph'].subRequests.length).to.equal(1); + it("result.n1_C1_graph.subRequests.length", function () { + expect(result.n1_C1_graph.subRequests.length).to.equal(1); }); - it("result['n1_C1_graph'].data.metric_paths.length", function () { - expect(result['n1_C1_graph'].data.metric_paths.length).to.equal(1); + it("result.n1_C1_graph.data.metric_paths.length", function () { + expect(result.n1_C1_graph.data.metric_paths.length).to.equal(1); }); - it("result['n2_C1'].subRequests.length", function () { - expect(result['n2_C1'].subRequests.length).to.equal(1); + it("result.n2_C1.subRequests.length", function () { + expect(result.n2_C1.subRequests.length).to.equal(1); }); - it("result['n2_C1'].data.metric_paths.length", function () { - expect(result['n2_C1'].data.metric_paths.length).to.equal(1); + it("result.n2_C1.data.metric_paths.length", function () { + expect(result.n2_C1.data.metric_paths.length).to.equal(1); }); - it("result['n1_C2'].subRequests.length", function () { - expect(result['n1_C2'].subRequests.length).to.equal(1); + it("result.n1_C2.subRequests.length", function () { + expect(result.n1_C2.subRequests.length).to.equal(1); }); - it("result['n1_C2'].data.metric_paths.length", function () { - expect(result['n1_C2'].data.metric_paths.length).to.equal(1); + it("result.n1_C2.data.metric_paths.length", function () { + expect(result.n1_C2.data.metric_paths.length).to.equal(1); }); }); @@ -541,7 +541,7 @@ describe('App.WidgetLoadAggregator', function () { } }; aggregator.runRequests(requests); - expect(mock.f1.calledWith(requests['r1'].data)).to.be.true; + expect(mock.f1.calledWith(requests.r1.data)).to.be.true; }); it("view destroyed", function () { var requests = { http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mixins/main/host/details/host_components/decommissionable_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/main/host/details/host_components/decommissionable_test.js b/ambari-web/test/mixins/main/host/details/host_components/decommissionable_test.js index fe89774..2d94d42 100644 --- a/ambari-web/test/mixins/main/host/details/host_components/decommissionable_test.js +++ b/ambari-web/test/mixins/main/host/details/host_components/decommissionable_test.js @@ -22,30 +22,6 @@ require('mixins/main/host/details/host_components/decommissionable'); var decommissionable, view, - statusCases = [ - { - status: App.HostComponentStatus.started, - expected: false - }, - { - status: 'status', - expected: true - } - ], - responseCases = [ - { - HostRoles: { - desired_admin_state: 'state' - }, - ServiceComponentInfo: {component_state: ''} - }, - { - HostRoles: { - desired_admin_state: null - }, - ServiceComponentInfo: {component_state: ''} - } - ], textCases = [ { available: true, http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mixins/main/service/configs/widget_popover_support_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/main/service/configs/widget_popover_support_test.js b/ambari-web/test/mixins/main/service/configs/widget_popover_support_test.js index 557ea91..449ff5d 100644 --- a/ambari-web/test/mixins/main/service/configs/widget_popover_support_test.js +++ b/ambari-web/test/mixins/main/service/configs/widget_popover_support_test.js @@ -16,14 +16,4 @@ * limitations under the License. */ -var App = require('app'); -var view; - -describe('App.WidgetPopoverSupport', function () { - - beforeEach(function () { - view = Em.View.create(App.WidgetPopoverSupport, {}); - }); - - -}); \ No newline at end of file +describe('App.WidgetPopoverSupport', function () {}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mixins/wizard/wizardEnableDone_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/wizard/wizardEnableDone_test.js b/ambari-web/test/mixins/wizard/wizardEnableDone_test.js index 7969f54..9116da8 100644 --- a/ambari-web/test/mixins/wizard/wizardEnableDone_test.js +++ b/ambari-web/test/mixins/wizard/wizardEnableDone_test.js @@ -20,9 +20,7 @@ var App = require('app'); describe('App.WizardEnableDone', function () { var baseObject = Em.Object.extend({ - statusChangeCallback: function (data) { - isSubmitDisabled: true - } + statusChangeCallback: function () {} }), mixedObject = baseObject.extend(App.WizardEnableDone), mixedObjectInstance; http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mixins/wizard/wizardProgressPageController_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/wizard/wizardProgressPageController_test.js b/ambari-web/test/mixins/wizard/wizardProgressPageController_test.js index 18a37cb..41d6a77 100644 --- a/ambari-web/test/mixins/wizard/wizardProgressPageController_test.js +++ b/ambari-web/test/mixins/wizard/wizardProgressPageController_test.js @@ -37,7 +37,7 @@ describe('App.wizardProgressPageControllerMixin', function() { }); sinon.spy(mixedObjectInstance, 'onCreateComponent'); sinon.spy(mixedObjectInstance, 'updateComponent'); - sinon.stub(mixedObjectInstance, 'checkInstalledComponents', function(componentName, hostNames) { + sinon.stub(mixedObjectInstance, 'checkInstalledComponents', function(componentName) { var def = $.Deferred(); var data = { 'ZOOKEEPER_SERVER': { @@ -106,7 +106,7 @@ describe('App.wizardProgressPageControllerMixin', function() { }); it('updateComponent is called', function () { // invoke callback - this.args.sender[this.args.success].apply(this.args.sender, [null, null, this.args.data]); + this.args.sender[this.args.success](null, null, this.args.data); expect(mixedObjectInstance.updateComponent.called).to.be.true; }); }); @@ -131,7 +131,7 @@ describe('App.wizardProgressPageControllerMixin', function() { }); it('updateComponent is called', function () { // invoke callback - this.args.sender[this.args.success].apply(this.args.sender, [null, null, this.args.data]); + this.args.sender[this.args.success](null, null, this.args.data); expect(mixedObjectInstance.updateComponent.called).to.be.true; }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/mock_data_setup/configs_mock_data.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mock_data_setup/configs_mock_data.js b/ambari-web/test/mock_data_setup/configs_mock_data.js index 694862b..ae54235 100644 --- a/ambari-web/test/mock_data_setup/configs_mock_data.js +++ b/ambari-web/test/mock_data_setup/configs_mock_data.js @@ -107,15 +107,15 @@ module.exports = { }); }); } else { - for (var serviceName in configTags) { - configTags[serviceName].forEach(function(tag) { + Object.keys(configTags).forEach(function (sName) { + configTags[sName].forEach(function(tag) { configTagsObject.push({ siteName: tag, tagName: "version1", newTagName: null }); }); - } + }); } return configTagsObject.uniq(); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/models/authentication_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/authentication_test.js b/ambari-web/test/models/authentication_test.js index f0002cd..ad825bd 100644 --- a/ambari-web/test/models/authentication_test.js +++ b/ambari-web/test/models/authentication_test.js @@ -53,12 +53,12 @@ describe('App.AuthenticationForm', function () { methods.forEach(function (method) { method.fields.forEach(function (field) { describe('#' + field + '.isRequired', function () { - for (var i = 2; i--; ) { + [2, 1, 0].forEach(function (i) { it('should be ' + i + ' dependent on ' + method.name + ' value', function () { form.getField(method.name).set('value', i); expect(form.getField(field).get('isRequired')).to.equal(i); }); - } + }); }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/models/configs/objects/service_config_property_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/configs/objects/service_config_property_test.js b/ambari-web/test/models/configs/objects/service_config_property_test.js index 7164602..2b4a297 100644 --- a/ambari-web/test/models/configs/objects/service_config_property_test.js +++ b/ambari-web/test/models/configs/objects/service_config_property_test.js @@ -54,56 +54,6 @@ var serviceConfigProperty, }) ], - components = [ - { - name: 'NameNode', - master: true - }, - { - name: 'SNameNode', - master: true - }, - { - name: 'JobTracker', - master: true - }, - { - name: 'HBase Master', - master: true - }, - { - name: 'Oozie Master', - master: true - }, - { - name: 'Hive Metastore', - master: true - }, - { - name: 'WebHCat Server', - master: true - }, - { - name: 'ZooKeeper Server', - master: true - }, - { - name: 'Ganglia', - master: true - }, - { - name: 'DataNode', - slave: true - }, - { - name: 'TaskTracker', - slave: true - }, - { - name: 'RegionServer', - slave: true - } - ], overridableFalseData = [ { isOverridable: false @@ -120,7 +70,8 @@ var serviceConfigProperty, { isOverridable: true, isEditable: true - }, { + }, + { isOverridable: true, overrides: [] }, http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/models/configs/objects/service_config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/configs/objects/service_config_test.js b/ambari-web/test/models/configs/objects/service_config_test.js index b3e8122..8a757ea 100644 --- a/ambari-web/test/models/configs/objects/service_config_test.js +++ b/ambari-web/test/models/configs/objects/service_config_test.js @@ -21,7 +21,6 @@ var App = require('app'); require('models/configs/objects/service_config'); var serviceConfig, - group, configs = [ Em.Object.create({ 'name': 'p1', http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/models/configs/theme/tab_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/configs/theme/tab_test.js b/ambari-web/test/models/configs/theme/tab_test.js index 813d997..3a5f21d 100644 --- a/ambari-web/test/models/configs/theme/tab_test.js +++ b/ambari-web/test/models/configs/theme/tab_test.js @@ -17,7 +17,6 @@ */ var App = require('app'); -var model; function getModel() { return App.Tab.createRecord(); @@ -25,10 +24,6 @@ function getModel() { describe('App.Tab', function () { - beforeEach(function () { - model = getModel(); - }); - App.TestAliases.testAsComputedSumBy(getModel(), 'errorsCount', 'sections', 'errorsCount'); App.TestAliases.testAsComputedIfThenElse(getModel(), 'tooltipMsg', 'isHiddenByFilter', Em.I18n.t('services.service.config.nothing.to.display') , ''); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/models/form_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/form_test.js b/ambari-web/test/models/form_test.js index 18c86c6..29ca459 100644 --- a/ambari-web/test/models/form_test.js +++ b/ambari-web/test/models/form_test.js @@ -194,6 +194,7 @@ describe('App.FormField', function () { }); }); + /*eslint-disable mocha-cleanup/asserts-limit */ describe('#validate', function () { it('should return error message', function () { formField.set('isRequired', true); @@ -206,6 +207,7 @@ describe('App.FormField', function () { expectError(''); }); }); + /*eslint-enable mocha-cleanup/asserts-limit */ describe('#isHiddenField', function () { hiddenCases.forEach(function (item) { http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/models/host_component_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/host_component_test.js b/ambari-web/test/models/host_component_test.js index 4266c3c..92e3d50 100644 --- a/ambari-web/test/models/host_component_test.js +++ b/ambari-web/test/models/host_component_test.js @@ -225,10 +225,10 @@ describe('App.HostComponent', function() { } ]; - it('reset statusClass to plain property', function () { + beforeEach(function () { hc.reopen({ statusClass: '' - }) + }); }); testCases.forEach(function (test) { it('statusClass - ' + test.statusClass, function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/models/host_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/host_test.js b/ambari-web/test/models/host_test.js index cbeca12..37092da 100644 --- a/ambari-web/test/models/host_test.js +++ b/ambari-web/test/models/host_test.js @@ -463,11 +463,12 @@ describe('App.Host', function () { } ]; - it('reset healthClass to plain property', function(){ + beforeEach(function() { host1.reopen({ healthClass: '' }); }); + testCases.forEach(function (test) { it('healthClass - ' + test.params.healthClass, function () { host1.set('healthClass', test.params.healthClass); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/models/service/hdfs_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/service/hdfs_test.js b/ambari-web/test/models/service/hdfs_test.js index 2eb1130..9f69dd0 100644 --- a/ambari-web/test/models/service/hdfs_test.js +++ b/ambari-web/test/models/service/hdfs_test.js @@ -18,7 +18,6 @@ var App = require('app'); -var modelSetup = require('test/init_model_test'); require('models/service/hdfs'); describe('App.HDFSService', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/models/service/yarn_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/service/yarn_test.js b/ambari-web/test/models/service/yarn_test.js index 9670092..55e1452 100644 --- a/ambari-web/test/models/service/yarn_test.js +++ b/ambari-web/test/models/service/yarn_test.js @@ -25,29 +25,6 @@ var yarnService, yarnServiceData = { id: 'yarn' }, - hostComponentsData = [ - { - id: 'ats', - componentName: 'APP_TIMELINE_SERVER', - host: { - id: 'host' - } - }, - { - id: 'nodemanager', - componentName: 'NODEMANAGER', - host: { - id: 'host' - } - }, - { - id: 'yarnclient', - componentName: 'YARN_CLIENT', - host: { - id: 'host' - } - } - ], configs = [ { properties: { @@ -56,38 +33,7 @@ var yarnService, tag: 'version2', type: 'yarn-site' } - ], - nodeCountCases = [ - { - assets: { - nodeManagersStarted: 0, - nodeManagersInstalled: 1, - nodeManagersTotal: 1, - nodeManagersCountActive: 0, - nodeManagersCountRebooted: 0, - nodeManagersCountUnhealthy: 0, - nodeManagersCountDecommissioned: 0 - }, - nodeManagersCountLost: 1 - }, - { - assets: { - nodeManagersStarted: 1, - nodeManagersInstalled: 1, - nodeManagersTotal: 1, - nodeManagersCountActive: 1, - nodeManagersCountRebooted: 1, - nodeManagersCountUnhealthy: 0, - nodeManagersCountDecommissioned: 0 - }, - nodeManagersCountLost: 0 - } - ], - setHostComponents = function () { - yarnService.reopen({ - hostComponents: hostComponentsData - }); - }; + ]; describe('App.YARNService', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/models/service_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/service_test.js b/ambari-web/test/models/service_test.js index eeb0de0..8643f5d 100644 --- a/ambari-web/test/models/service_test.js +++ b/ambari-web/test/models/service_test.js @@ -61,72 +61,6 @@ var service, property: 'isStarted' } ], - services = [ - { - name: 'HDFS', - configurable: true - }, - { - name: 'YARN', - configurable: true - }, - { - name: 'MAPREDUCE2', - configurable: true - }, - { - name:'TEZ', - clientOnly: true, - configurable: true - }, - { - name: 'HBASE', - configurable: true - }, - { - name: 'HIVE', - configurable: true - }, - { - name: 'FLUME', - configurable: true - }, - { - name: 'FALCON', - configurable: true - }, - { - name: 'STORM', - configurable: true - }, - { - name: 'OOZIE', - configurable: true - }, - { - name: 'GANGLIA', - configurable: true - }, - { - name: 'ZOOKEEPER', - configurable: true - }, - { - name: 'PIG', - configurable: true, - clientOnly: true - }, - { - name: 'SQOOP', - clientOnly: true - }, - { - name: 'HUE', - configurable: true - } - ], - clientsOnly = services.filterProperty('clientOnly').mapProperty('name'), - configurable = services.filterProperty('configurable').mapProperty('name'), hostComponentsDataFalse = [ [], [ http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/models/stack_version/repository_version_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/stack_version/repository_version_test.js b/ambari-web/test/models/stack_version/repository_version_test.js index 7ec1bf4..bbb98a3 100644 --- a/ambari-web/test/models/stack_version/repository_version_test.js +++ b/ambari-web/test/models/stack_version/repository_version_test.js @@ -42,19 +42,22 @@ describe('App.RepositoryVersion', function () { before(function () { sinon.stub(App, 'get').returns(['host1']); }); + + beforeEach(function () { + model = getModel(); + }); + after(function () { App.get.restore(); }); it("stackVersion is null", function() { - var model = getModel(); model.set('stackVersion', null); model.propertyDidChange('notInstalledHosts'); expect(model.get('notInstalledHosts')).to.eql(['host1']); }); it("stackVersion has notInstalledHosts array", function() { - var model = getModel(); model.set('stackVersion', Em.Object.create({ notInstalledHosts: ['host2'] })); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/router_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/router_test.js b/ambari-web/test/router_test.js index 78540e7..cf638d9 100644 --- a/ambari-web/test/router_test.js +++ b/ambari-web/test/router_test.js @@ -450,7 +450,6 @@ describe('App.Router', function () { }); describe("#getAuthenticated", function() { - var router; beforeEach(function () { router = App.Router.create(); this.mockGetCurrentLocationUrl = sinon.stub(router, 'getCurrentLocationUrl'); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/routes/views_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/routes/views_test.js b/ambari-web/test/routes/views_test.js index b5c5cf7..19dc343 100644 --- a/ambari-web/test/routes/views_test.js +++ b/ambari-web/test/routes/views_test.js @@ -23,7 +23,7 @@ describe('routes/views', function() { var route = routeClass.create().get('viewDetails').create(); describe("#parseViewPath", function() { - var testCases = [ + [ { url: 'viewName', result: '' http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/utils/batch_scheduled_requests_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/batch_scheduled_requests_test.js b/ambari-web/test/utils/batch_scheduled_requests_test.js index 11ba710..f564824 100644 --- a/ambari-web/test/utils/batch_scheduled_requests_test.js +++ b/ambari-web/test/utils/batch_scheduled_requests_test.js @@ -99,8 +99,9 @@ describe('batch_scheduled_requests', function() { sinon.spy(batchUtils, 'showRollingRestartPopup'); sinon.spy(batchUtils, 'showWarningRollingRestartPopup'); sinon.stub(App, 'get', function(k) { - if ('components.rollinRestartAllowed' === k) + if ('components.rollinRestartAllowed' === k) { return ['DATANODE', 'TASKTRACKER', 'NODEMANAGER', 'HBASE_REGIONSERVER', 'SUPERVISOR']; + } return Em.get(App, k); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/utils/blueprint_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/blueprint_test.js b/ambari-web/test/utils/blueprint_test.js index bda0b58..6337293 100644 --- a/ambari-web/test/utils/blueprint_test.js +++ b/ambari-web/test/utils/blueprint_test.js @@ -438,8 +438,8 @@ describe('utils/blueprint', function() { describe('#_generateHostMap', function() { it('generate map', function() { var map = blueprintUtils._generateHostMap({}, ['h1','h2', 'h1'],'c1'); - expect(map['h1'][0]).to.eql('c1'); - expect(map['h2'][0]).to.eql('c1'); + expect(map.h1[0]).to.eql('c1'); + expect(map.h2[0]).to.eql('c1'); }); it('skip generations as hosts is empty', function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/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 c88c745..13e0fa5 100644 --- a/ambari-web/test/utils/config_test.js +++ b/ambari-web/test/utils/config_test.js @@ -22,7 +22,6 @@ require('utils/configs_collection'); require('utils/config'); require('models/service/hdfs'); var setups = require('test/init_model_test'); -var modelSetup = setups.configs; function dummyCopy(val) { return JSON.parse(JSON.stringify(val)); @@ -59,7 +58,7 @@ describe('App.config', function () { describe('two configs into textarea', function () { var result; beforeEach(function () { - result = App.config.fileConfigsIntoTextarea.call(App.config, configs, filename); + result = App.config.fileConfigsIntoTextarea(configs, filename); }); it('One config is returned', function () { expect(result.length).to.equal(1); @@ -77,7 +76,7 @@ describe('App.config', function () { newConfigs.push(dummyCopy(c3)); var result; beforeEach(function () { - result = App.config.fileConfigsIntoTextarea.call(App.config, newConfigs, filename); + result = App.config.fileConfigsIntoTextarea(newConfigs, filename); }); it('One config is returned', function () { expect(result.length).to.equal(1); @@ -97,7 +96,7 @@ describe('App.config', function () { var result; beforeEach(function () { - result = App.config.fileConfigsIntoTextarea.call(App.config, newConfigs, filename); + result = App.config.fileConfigsIntoTextarea(newConfigs, filename); }); it('Two configs are returned', function () { @@ -115,7 +114,7 @@ describe('App.config', function () { describe('none configs into empty textarea', function () { var result; beforeEach(function () { - result = App.config.fileConfigsIntoTextarea.call(App.config, [], 'capacity-scheduler.xml'); + result = App.config.fileConfigsIntoTextarea([], 'capacity-scheduler.xml'); }); it('One config is returned', function () { expect(result.length).to.equal(1); @@ -136,7 +135,7 @@ describe('App.config', function () { newConfigs.push(dummyCopy(c3)); var result; beforeEach(function () { - result = App.config.fileConfigsIntoTextarea.call(App.config, newConfigs, 'capacity-scheduler.xml', [c3]); + result = App.config.fileConfigsIntoTextarea(newConfigs, 'capacity-scheduler.xml', [c3]); }); it('Two configs are returned', function () { expect(result.length).to.equal(2); @@ -194,7 +193,7 @@ describe('App.config', function () { describe('config1=value1 to one config', function () { var result; beforeEach(function () { - result = App.config.textareaIntoFileConfigs.call(App.config, testData[0].configs, filename); + result = App.config.textareaIntoFileConfigs(testData[0].configs, filename); }); it('One config is returned', function () { expect(result.length).to.equal(1); @@ -213,7 +212,7 @@ describe('App.config', function () { describe('config1=value1\\nconfig2=value2\\n to two configs', function () { var result; beforeEach(function () { - result = App.config.textareaIntoFileConfigs.call(App.config, testData[1].configs, filename); + result = App.config.textareaIntoFileConfigs(testData[1].configs, filename); }); it('Two configs are returned', function (){ expect(result.length).to.equal(2); @@ -241,7 +240,7 @@ describe('App.config', function () { describe('config1=value1,value2\n to one config', function () { var result; beforeEach(function () { - result = App.config.textareaIntoFileConfigs.call(App.config, testData[2].configs, filename); + result = App.config.textareaIntoFileConfigs(testData[2].configs, filename); }); it('One config is returned', function () { expect(result.length).to.equal(1); @@ -260,7 +259,7 @@ describe('App.config', function () { describe('config1=value1 config2=value2 to two configs', function () { var result; beforeEach(function () { - result = App.config.textareaIntoFileConfigs.call(App.config, testData[3].configs, filename); + result = App.config.textareaIntoFileConfigs(testData[3].configs, filename); }); it('One config is returned', function () { expect(result.length).to.equal(1); @@ -676,9 +675,9 @@ describe('App.config', function () { it('creates override with save properties as original config', function() { var override = App.config.createOverride(configProperty, {}, group); - for (var key in template) { + Object.keys(template).forEach(function (key) { expect(override.get(key)).to.eql(template[key]); - } + }); }); describe('overrides some values that should be different for override', function() { @@ -711,9 +710,9 @@ describe('App.config', function () { }; var override = App.config.createOverride(configProperty, overridenTemplate, group); - for (var key in overridenTemplate) { + Object.keys(overridenTemplate).forEach(function (key) { expect(override.get(key)).to.eql(overridenTemplate[key]); - } + }); }); it('throws error due to undefined configGroup', function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/utils/configs/config_initializer_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/configs/config_initializer_test.js b/ambari-web/test/utils/configs/config_initializer_test.js index f8eb825..32f8b14 100644 --- a/ambari-web/test/utils/configs/config_initializer_test.js +++ b/ambari-web/test/utils/configs/config_initializer_test.js @@ -21,62 +21,7 @@ var App = require('app'); require('models/configs/objects/service_config_property'); require('utils/configs/config_initializer'); -var serviceConfig, - group, - serviceConfigProperty, - - components = [ - { - name: 'NameNode', - master: true - }, - { - name: 'SNameNode', - master: true - }, - { - name: 'JobTracker', - master: true - }, - { - name: 'HBase Master', - master: true - }, - { - name: 'Oozie Master', - master: true - }, - { - name: 'Hive Metastore', - master: true - }, - { - name: 'WebHCat Server', - master: true - }, - { - name: 'ZooKeeper Server', - master: true - }, - { - name: 'Ganglia', - master: true - }, - { - name: 'DataNode', - slave: true - }, - { - name: 'TaskTracker', - slave: true - }, - { - name: 'RegionServer', - slave: true - } - ], - masters = components.filterProperty('master'), - slaves = components.filterProperty('slave'); +var serviceConfigProperty; describe('App.ConfigInitializer', function () { @@ -357,7 +302,7 @@ describe('App.ConfigInitializer', function () { App.get.restore(); }); - cases['hive_database'].forEach(function (item) { + cases.hive_database.forEach(function (item) { var title = 'hive_database value should be set to {0}'; describe(title.format(item.value), function () { @@ -410,10 +355,10 @@ describe('App.ConfigInitializer', function () { }); }); - it(cases['hive_master_hosts'].title, function () { + it(cases.hive_master_hosts.title, function () { serviceConfigProperty.set('name', 'hive_master_hosts'); - App.ConfigInitializer.initialValue(serviceConfigProperty, cases['hive_master_hosts'].localDB, []); - expect(serviceConfigProperty.get('value')).to.equal(cases['hive_master_hosts'].value); + App.ConfigInitializer.initialValue(serviceConfigProperty, cases.hive_master_hosts.localDB, []); + expect(serviceConfigProperty.get('value')).to.equal(cases.hive_master_hosts.value); }); it(cases['hive.metastore.uris'].title, function () { @@ -432,7 +377,7 @@ describe('App.ConfigInitializer', function () { recommendedValue: cases['templeton.hive.properties'].recommendedValue, value: cases['templeton.hive.properties'].recommendedValue }); - App.ConfigInitializer.initialValue(serviceConfigProperty, cases['templeton.hive.properties'].localDB, {'hive.metastore.uris': cases['templeton.hive.properties'].recommendedValue}); + App.ConfigInitializer.initialValue(serviceConfigProperty, cases['templeton.hive.properties'].localDB, {'hive.metastore.uris': cases['templeton.hive.properties'].recommendedValue}); expect(serviceConfigProperty.get('value')).to.equal(cases['templeton.hive.properties'].value); expect(serviceConfigProperty.get('recommendedValue')).to.equal(cases['templeton.hive.properties'].value); }); @@ -442,7 +387,7 @@ describe('App.ConfigInitializer', function () { name: 'yarn.resourcemanager.zk-address', recommendedValue: cases['yarn.resourcemanager.zk-address'].recommendedValue }); - App.ConfigInitializer.initialValue(serviceConfigProperty, cases['yarn.resourcemanager.zk-address'].localDB, cases['yarn.resourcemanager.zk-address'].dependencies); + App.ConfigInitializer.initialValue(serviceConfigProperty, cases['yarn.resourcemanager.zk-address'].localDB, cases['yarn.resourcemanager.zk-address'].dependencies); expect(serviceConfigProperty.get('value')).to.equal(cases['yarn.resourcemanager.zk-address'].value); expect(serviceConfigProperty.get('recommendedValue')).to.equal(cases['yarn.resourcemanager.zk-address'].value); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/utils/configs/database_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/configs/database_test.js b/ambari-web/test/utils/configs/database_test.js index e5f9d26..05f21de 100644 --- a/ambari-web/test/utils/configs/database_test.js +++ b/ambari-web/test/utils/configs/database_test.js @@ -16,7 +16,6 @@ * limitations under the License. */ -var App = require('app'); var dbUtils = require('utils/configs/database'); describe('Database Utils', function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/utils/data_manipulation_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/data_manipulation_test.js b/ambari-web/test/utils/data_manipulation_test.js index fec5625..50eb6b5 100644 --- a/ambari-web/test/utils/data_manipulation_test.js +++ b/ambari-web/test/utils/data_manipulation_test.js @@ -16,9 +16,9 @@ * limitations under the License. */ -var data_manipulation = require('utils/data_manipulation'); +var dataManipulation = require('utils/data_manipulation'); -describe('data_manipulation', function () { +describe('dataManipulation', function () { describe('#rejectPropertyValues', function () { @@ -31,7 +31,7 @@ describe('data_manipulation', function () { ], key = 'n', valuesToReject = ['v2', 'v3']; - var result = data_manipulation.rejectPropertyValues(collection, key, valuesToReject); + var result = dataManipulation.rejectPropertyValues(collection, key, valuesToReject); expect(result).to.eql([ {n: 'v1'}, {n: 'v4'} @@ -51,7 +51,7 @@ describe('data_manipulation', function () { ], key = 'n', valuesToFilter = ['v2', 'v3']; - var result = data_manipulation.filterPropertyValues(collection, key, valuesToFilter); + var result = dataManipulation.filterPropertyValues(collection, key, valuesToFilter); expect(result).to.eql([ {n: 'v2'}, {n: 'v3'} @@ -70,7 +70,7 @@ describe('data_manipulation', function () { {n: 'v4'} ], key = 'n'; - var result = data_manipulation.groupPropertyValues(collection, key); + var result = dataManipulation.groupPropertyValues(collection, key); expect(JSON.stringify(result)).to.equal(JSON.stringify({ v1: [ {n: 'v1'} http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/utils/date/date_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/date/date_test.js b/ambari-web/test/utils/date/date_test.js index 1ccfb31..3d61c90 100644 --- a/ambari-web/test/utils/date/date_test.js +++ b/ambari-web/test/utils/date/date_test.js @@ -16,21 +16,12 @@ * limitations under the License. */ -var Ember = require('ember'); var App = require('app'); - -var validator = require('utils/validator'); var date = require('utils/date/date'); describe('date', function () { - var correct_tests = Em.A([ - {t: 1349752195000, e: 'Tue, Oct 09, 2012 03:09', e2: 'Tue Oct 09 2012'}, - {t: 1367752195000, e: 'Sun, May 05, 2013 11:09', e2: 'Sun May 05 2013'}, - {t: 1369952195000, e: 'Thu, May 30, 2013 22:16', e2: 'Thu May 30 2013'} - ]); - - var incorrect_tests = Em.A([ + var incorrectTests = Em.A([ {t: null}, {t: ''}, {t: false}, @@ -104,7 +95,7 @@ describe('date', function () { }); describe('Incorrect data', function(){ - incorrect_tests.forEach(function(test) { + incorrectTests.forEach(function(test) { it(test.t, function() { expect(date.timingFormat(test.t)).to.equal(null); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/utils/helper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/helper_test.js b/ambari-web/test/utils/helper_test.js index 910cc9f..7d78678 100644 --- a/ambari-web/test/utils/helper_test.js +++ b/ambari-web/test/utils/helper_test.js @@ -181,8 +181,9 @@ describe('utils/helper', function() { }); it('should sort array', function() { result.forEach(function(resultObj, index, resultArr) { - if (index > resultArr.length - 1) + if (index > resultArr.length - 1) { expect(resultObj.a < resultArr[index + 1].a).to.eql(false); + } }); }); it('should try to sort without throwing exception', function(){ @@ -244,7 +245,7 @@ describe('utils/helper', function() { beforeEach(appendDiv); afterEach(removeDiv); it('should add tooltip', function() { - var tooltip = App.tooltip($('#tooltip-test')); + App.tooltip($('#tooltip-test')); expect($('#tooltip-test').data('tooltip').enabled).to.eql(true); }); }); @@ -252,7 +253,7 @@ describe('utils/helper', function() { beforeEach(appendDiv); afterEach(removeDiv); it('should add popover', function() { - var tooltip = App.popover($('#tooltip-test')); + App.popover($('#tooltip-test')); expect($('#tooltip-test').data('popover').enabled).to.eql(true); }); }); @@ -304,13 +305,11 @@ describe('utils/helper', function() { 'FALCON': 'Falcon', 'falcon': 'Falcon' }; - for (var inputName in tests) { - (function(name) { - it(testMessage.format(name, tests[name]), function() { - expect(App.format.normalizeNameBySeparators(name, ["-", "_", " "])).to.eql(tests[name]); - }); - })(inputName) - } + Object.keys(tests).forEach(function (inputName) { + it(testMessage.format(inputName, tests[inputName]), function() { + expect(App.format.normalizeNameBySeparators(inputName, ["-", "_", " "])).to.eql(tests[inputName]); + }); + }); }); describe('#normalizeName()', function() { @@ -386,13 +385,11 @@ describe('utils/helper', function() { 'ZOOKEEPER_SERVICE_CHECK': 'ZooKeeper Service Check', 'CLIENT': 'Client' }; - for (var inputName in tests) { - (function(name) { - it(testMessage.format(name, tests[name]), function() { - expect(App.format.normalizeName(name)).to.eql(tests[name]); - }); - })(inputName) - } + Object.keys(tests).forEach(function (inputName) { + it(testMessage.format(inputName, tests[inputName]), function() { + expect(App.format.normalizeName(inputName)).to.eql(tests[inputName]); + }); + }); }); describe('#kdcErrorMsg()', function() { var tests = [ http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/utils/host_progress_popup_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/host_progress_popup_test.js b/ambari-web/test/utils/host_progress_popup_test.js index 8ef64d2..1d143a7 100644 --- a/ambari-web/test/utils/host_progress_popup_test.js +++ b/ambari-web/test/utils/host_progress_popup_test.js @@ -26,76 +26,7 @@ require('utils/host_progress_popup'); describe('App.HostPopup', function () { - var services = [ - { - displayName: "Start service WebHCat", - hosts: [ - { - logTasks: [ - { - Tasks: { - command: "START", - host_name: "ip-10-12-123-90.ec2.internal", - role: "WEBHCAT_SERVER", - status: "QUEUED" - }, - href: "http://ec2-54-224-233-43.compute-1.amazonaws.com:8080/api/v1/clusters/mycluster/requests/23/tasks/94" - } - ], - name: "ip-10-12-123-90.ec2.internal", - publicName: "ip-10-12-123-90.ec2.internal", - serviceName: "Start service WebHCat" - } - ], - isRunning: false - }, - { - displayName: "Start service Hive/HCat", - hosts: [ - { - logTasks: [ - { - Tasks: { - command: "INSTALL", - host_name: "ip-10-12-123-90.ec2.internal", - status: "COMPLETED" - }, - href: "http://ec2-54-224-233-43.compute-1.amazonaws.com:8080/api/v1/clusters/mycluster/requests/15/tasks/76" - } - ], - name: "ip-10-12-123-90.ec2.internal", - publicName: "ip-10-12-123-90.ec2.internal", - serviceName: "Start service Hive/HCat" - }, - { - logTasks: [ - { - Tasks: { - command: "START", - host_name: "ip-10-33-7-23.ec2.internal", - status: "COMPLETED" - }, - href: "http://ec2-54-224-233-43.compute-1.amazonaws.com:8080/api/v1/clusters/mycluster/requests/15/tasks/78" - }, - { - Tasks: { - command: "START", - host_name: "ip-10-33-7-23.ec2.internal", - status: "COMPLETED" - }, - href: "http://ec2-54-224-233-43.compute-1.amazonaws.com:8080/api/v1/clusters/mycluster/requests/15/tasks/79" - } - ], - name: "ip-10-33-7-23.ec2.internal", - publicName: "ip-10-33-7-23.ec2.internal", - serviceName: "Start service Hive/HCat" - } - ], - isRunning: false - } - ]; - - var test_tasks = [ + var testTasks = [ { t: [ { @@ -346,17 +277,17 @@ describe('App.HostPopup', function () { }); describe('#getStatus', function() { - test_tasks.forEach(function(test_task) { - it(test_task.m, function() { - expect(App.HostPopup.getStatus(test_task.t)[0]).to.equal(test_task.r); + testTasks.forEach(function(testTask) { + it(testTask.m, function() { + expect(App.HostPopup.getStatus(testTask.t)[0]).to.equal(testTask.r); }); }); }); describe('#getProgress', function() { - test_tasks.forEach(function(test_task) { - it(test_task.m, function() { - expect(App.HostPopup.getProgress(test_task.t)).to.equal(test_task.p); + testTasks.forEach(function(testTask) { + it(testTask.m, function() { + expect(App.HostPopup.getProgress(testTask.t)).to.equal(testTask.p); }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/utils/load_timer_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/load_timer_test.js b/ambari-web/test/utils/load_timer_test.js index 4e84134..8005ff0 100644 --- a/ambari-web/test/utils/load_timer_test.js +++ b/ambari-web/test/utils/load_timer_test.js @@ -16,8 +16,6 @@ * limitations under the License. */ -var misc = require('utils/load_timer'); - describe('App.loadTimer', function () { window.performance = { @@ -38,7 +36,7 @@ describe('App.loadTimer', function () { describe("#start()", function() { it("time should be cached", function() { App.loadTimer.start('test'); - expect(App.loadTimer.get('timeStampCache')['test']).to.be.an('number'); + expect(App.loadTimer.get('timeStampCache.test')).to.be.an('number'); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/utils/misc_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/misc_test.js b/ambari-web/test/utils/misc_test.js index c54df7e3..432459e 100644 --- a/ambari-web/test/utils/misc_test.js +++ b/ambari-web/test/utils/misc_test.js @@ -36,7 +36,7 @@ describe('misc', function () { expect(misc.formatBandwidth(test.i)).to.equal(test.e); }); }); - it('NaN to NaN' + ' ', function () { + it('NaN to NaN', function () { expect(isNaN(misc.formatBandwidth(NaN))).to.equal(true); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/40aac602/ambari-web/test/utils/number_utils_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/number_utils_test.js b/ambari-web/test/utils/number_utils_test.js index 513fc6a..952ab89 100644 --- a/ambari-web/test/utils/number_utils_test.js +++ b/ambari-web/test/utils/number_utils_test.js @@ -268,7 +268,7 @@ describe('utils/number_utils', function() { ]; var message = 'cardinality `{0}`. {1} value should be {2}'; tests.forEach(function(test) { - it(message.format('' + test.cardinality, (test.isMax ? 'maximum' : 'minimum'), test.e), function() { + it(message.format('' + test.cardinality, test.isMax ? 'maximum' : 'minimum', test.e), function() { expect(numberUtils.getCardinalityValue(test.cardinality, test.isMax)).to.be.eql(test.e); }); })