Procházet zdrojové kódy

AMBARI-8891. Ambari UI Unit tests. Fix "floating" tests (onechiporenko)

Oleg Nechiporenko před 10 roky
rodič
revize
5df4636fb7

+ 1 - 1
ambari-web/app/controllers/wizard/step9_controller.js

@@ -1097,7 +1097,7 @@ App.WizardStep9Controller = Em.Controller.extend({
           dfd.resolve();
         });
     }
-    return dfd.promise()
+    return dfd.promise();
   },
 
   /**

+ 1 - 1
ambari-web/package.json

@@ -36,7 +36,7 @@
   },
   "scripts": {
     "start": "brunch watch --server",
-    "test": "mocha-phantomjs public/test/test.html"
+    "test": "mocha-phantomjs -R min public/test/test.html"
   },
   "engines": {
     "node": "~0.6.10 || 0.8 || 0.9 || 0.10"

+ 1 - 1
ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js

@@ -538,7 +538,7 @@ describe('App.ManageAlertNotificationsController', function () {
 
     it("should send ajax request", function () {
 
-      controller.createAlertNotification();
+      controller.updateAlertNotification();
       expect(App.ajax.send.calledOnce).to.be.true;
     });
 

+ 0 - 10
ambari-web/test/controllers/main/service_test.js

@@ -272,16 +272,6 @@ describe('App.MainServiceController', function () {
 
   });
 
-  describe('#allServicesCallSuccessCallback', function() {
-
-    it('should set status to FAIL', function() {
-      var params = {query: Em.Object.create({status: ''})};
-      mainServiceController.allServicesCallSuccessCallback({Requests: {id: 1}}, {}, params);
-      expect(params.query.get('status')).to.equal('SUCCESS');
-    });
-
-  });
-
   describe('#allServicesCallErrorCallback', function() {
 
     it('should set status to FAIL', function() {

+ 4 - 1
ambari-web/test/controllers/main/views_controller_test.js

@@ -19,9 +19,12 @@
 var App = require('app');
 require('controllers/main/views_controller');
 
+var mainViewsController;
 describe('MainViewsController', function () {
 
-  var mainViewsController = App.MainViewsController.create();
+  beforeEach(function () {
+    mainViewsController = App.MainViewsController.create();
+  });
 
   describe('#loadAmbariViews()', function () {
     beforeEach(function () {

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 393 - 201
ambari-web/test/controllers/wizard/step3_test.js


+ 9 - 31
ambari-web/test/controllers/wizard/step9_test.js

@@ -30,6 +30,7 @@ require('utils/ajax/ajax');
 var modelSetup = require('test/init_model_test');
 var c, obj;
 describe('App.InstallerStep9Controller', function () {
+
   beforeEach(function () {
     modelSetup.setupStackServiceComponent();
     c = App.WizardStep9Controller.create({
@@ -37,6 +38,9 @@ describe('App.InstallerStep9Controller', function () {
       saveClusterStatus: Em.K,
       saveInstalledHosts: Em.K,
       togglePreviousSteps: Em.K,
+      setFinishState: Em.K,
+      changeParseHostInfo: Em.K,
+      parseHostInfoPolling: Em.K,
       wizardController: Em.Object.create({
         requestsId: [],
         cluster: {oldRequestsId: []},
@@ -58,6 +62,7 @@ describe('App.InstallerStep9Controller', function () {
       };
     });
   });
+
   afterEach(function () {
     modelSetup.cleanStackServiceComponent();
     App.ajax.send.restore();
@@ -1089,34 +1094,18 @@ describe('App.InstallerStep9Controller', function () {
     });
   });
 
-  describe('#getLogsByRequest', function () {
-    beforeEach(function () {
-      sinon.stub(c, 'togglePreviousSteps', Em.K);
-      sinon.stub(c, 'loadLogData', Em.K);
-    });
-    afterEach(function () {
-      c.togglePreviousSteps.restore();
-      c.loadLogData.restore();
-    });
-    it('should call App.ajax.send with provided data', function () {
-      var polling = 1;
-      var requestId = 2;
-      c.set('content', {cluster: {name: 3}});
-      c.set('numPolls', 4);
-      c.getLogsByRequest(polling, requestId);
-      expect(App.ajax.send.args[0][0].data).to.eql({polling: polling, requestId: requestId, cluster: 3, numPolls: 4});
-    });
-  });
-
   describe('#doPolling', function () {
+
     beforeEach(function () {
       sinon.stub(c, 'getLogsByRequest', Em.K);
       sinon.stub(c, 'togglePreviousSteps', Em.K);
     });
+
     afterEach(function () {
       c.getLogsByRequest.restore();
       c.togglePreviousSteps.restore();
     });
+
     it('should increment numPolls if testMode', function () {
       App.set('testMode', true);
       c.set('numPolls', 0);
@@ -1124,24 +1113,13 @@ describe('App.InstallerStep9Controller', function () {
       expect(c.get('numPolls')).to.equal(1);
       App.set('testMode', false);
     });
+
     it('should call getLogsByRequest', function () {
       c.set('content', {cluster: {requestId: 1}});
       c.doPolling();
       expect(c.getLogsByRequest.calledWith(true, 1)).to.equal(true);
     });
-  });
 
-  describe('#isAllComponentsInstalled', function () {
-    it('shouldn\'t call App.ajax.send', function () {
-      c.set('content', {controllerName: 'addServiceController'});
-      c.isAllComponentsInstalled();
-      expect(App.ajax.send.called).to.equal(false);
-    });
-    it('should call App.ajax.send', function () {
-      c.set('content', Ember.Object.create({cluster: {name: 'n'}, controllerName: 'installerController'}));
-      c.isAllComponentsInstalled();
-      expect(App.ajax.send.args[0][0].data).to.eql({cluster: 'n'});
-    });
   });
 
   describe('#isAllComponentsInstalledErrorCallback', function () {

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů