Procházet zdrojové kódy

AMBARI-7520. Fix UI Unit tests. (onechiporenko)

Oleg Nechiporenko před 10 roky
rodič
revize
9e2a81d618

+ 1 - 60
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);

+ 24 - 22
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);

+ 0 - 10
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({

+ 0 - 40
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 = [