Browse Source

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

Oleg Nechiporenko 11 years ago
parent
commit
0e01b1807d

+ 1 - 0
ambari-web/app/assets/test/tests.js

@@ -103,6 +103,7 @@ require('test/views/common/quick_link_view_test');
 require('test/views/common/rolling_restart_view_test');
 require('test/views/common/rolling_restart_view_test');
 require('test/views/main/dashboard_test');
 require('test/views/main/dashboard_test');
 require('test/views/main/dashboard/widget_test');
 require('test/views/main/dashboard/widget_test');
+require('test/views/main/dashboard/widgets_test');1
 require('test/views/main/dashboard/widgets/text_widget_test');
 require('test/views/main/dashboard/widgets/text_widget_test');
 require('test/views/main/dashboard/widgets/uptime_text_widget_test');
 require('test/views/main/dashboard/widgets/uptime_text_widget_test');
 require('test/views/main/dashboard/widgets/node_managers_live_test');
 require('test/views/main/dashboard/widgets/node_managers_live_test');

+ 2 - 1
ambari-web/test/controllers/global/update_controller_test.js

@@ -189,7 +189,8 @@ describe('App.UpdateController', function () {
             }
             }
           }
           }
         ],
         ],
-        result: ["host_components/metrics/flume/flume"]
+        result: ["host_components/metrics/flume/flume,"+
+          "host_components/processes/HostComponentProcess"]
       },
       },
       {
       {
         title: 'YARN service',
         title: 'YARN service',

+ 127 - 0
ambari-web/test/views/main/dashboard/widgets_test.js

@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+require('messages');
+var filters = require('views/common/filter_view');
+require('mixins/common/userPref');
+require('mixins/common/localStorage');
+require('views/main/dashboard/widgets');
+var mainDashboardWidgetsView;
+
+describe('App.MainDashboardWidgetsView', function() {
+
+  beforeEach(function() {
+    mainDashboardWidgetsView = App.MainDashboardWidgetsView.create();
+  });
+
+  describe('#setInitPrefObject', function() {
+    var hdfs_widgets_count = 7;
+    var mapreduce_widgets_count = 7;
+    var hbase_widgets_count = 4;
+    var yarn_widgets_count = 4;
+    var total_widgets_count = 27;
+    var tests = Em.A([
+      {
+        models: {
+          hdfs_model: null,
+          mapreduce_model: null,
+          hbase_model: null,
+          yarn_model: null
+        },
+        e: {
+          visibleL: total_widgets_count - hdfs_widgets_count - mapreduce_widgets_count - hbase_widgets_count - yarn_widgets_count - 1,
+          hiddenL: 0
+        },
+        m: 'All models are null'
+      },
+      {
+        models: {
+          hdfs_model: {},
+          mapreduce_model: null,
+          hbase_model: null,
+          yarn_model: null
+        },
+        e: {
+          visibleL: total_widgets_count  - mapreduce_widgets_count - hbase_widgets_count - yarn_widgets_count - 1,
+          hiddenL: 0
+        },
+        m: 'mapreduce_model, hbase_model, yarn_model are null'
+      },
+      {
+        models: {
+          hdfs_model: {},
+          mapreduce_model: {},
+          hbase_model: null,
+          yarn_model: null
+        },
+        e: {
+          visibleL: total_widgets_count - hbase_widgets_count - yarn_widgets_count - 1,
+          hiddenL: 0
+        },
+        m: 'hbase_model and yarn_model are null'
+      },
+      {
+        models: {
+          hdfs_model: {},
+          mapreduce_model: {},
+          hbase_model: {},
+          yarn_model: null
+        },
+        e: {
+          visibleL: total_widgets_count - yarn_widgets_count - 1,
+          hiddenL: 1
+        },
+        m: 'yarn_model is null'
+      },
+      {
+        models: {
+          hdfs_model: {},
+          mapreduce_model: {},
+          hbase_model: {},
+          yarn_model: {}
+        },
+        e: {
+          visibleL: total_widgets_count - 1,
+          hiddenL: 1
+        },
+        m: 'All models are not null'
+      }
+    ]);
+    tests.forEach(function(test) {
+      it(test.m, function() {
+        mainDashboardWidgetsView.set('hdfs_model', test.models.hdfs_model);
+        mainDashboardWidgetsView.set('mapreduce_model', test.models.mapreduce_model);
+        mainDashboardWidgetsView.set('hbase_model', test.models.hbase_model);
+        mainDashboardWidgetsView.set('yarn_model', test.models.yarn_model);
+        mainDashboardWidgetsView.setInitPrefObject();
+        expect(mainDashboardWidgetsView.get('initPrefObject.visible.length')).to.equal(test.e.visibleL);
+        expect(mainDashboardWidgetsView.get('initPrefObject.hidden.length')).to.equal(test.e.hiddenL);
+      });
+    });
+  });
+
+  describe('#persistKey', function() {
+    App.router.set('loginName', 'tdk');
+    it('Check it', function() {
+      expect(mainDashboardWidgetsView.get('persistKey')).to.equal('user-pref-tdk-dashboard');
+    });
+  });
+
+});

+ 4 - 95
ambari-web/test/views/main/dashboard_test.js

@@ -21,102 +21,11 @@ var App = require('app');
 require('messages');
 require('messages');
 var filters = require('views/common/filter_view');
 var filters = require('views/common/filter_view');
 require('views/main/dashboard');
 require('views/main/dashboard');
-
+var mainDashboardView;
 describe('App.MainDashboardView', function() {
 describe('App.MainDashboardView', function() {
 
 
-  var mainDashboardView = App.MainDashboardView.create();
-
-  describe('#setInitPrefObject', function() {
-    var hdfs_widgets_count = 7;
-    var mapreduce_widgets_count = 7;
-    var hbase_widgets_count = 4;
-    var yarn_widgets_count = 4;
-    var total_widgets_count = 27;
-    var tests = [
-      {
-        models: {
-          hdfs_model: null,
-          mapreduce_model: null,
-          hbase_model: null,
-          yarn_model: null
-        },
-        e: {
-          visibleL: total_widgets_count - hdfs_widgets_count - mapreduce_widgets_count - hbase_widgets_count - yarn_widgets_count - 1,
-          hiddenL: 0
-        },
-        m: 'All models are null'
-      },
-      {
-        models: {
-          hdfs_model: {},
-          mapreduce_model: null,
-          hbase_model: null,
-          yarn_model: null
-        },
-        e: {
-          visibleL: total_widgets_count  - mapreduce_widgets_count - hbase_widgets_count - yarn_widgets_count - 1,
-          hiddenL: 0
-        },
-        m: 'mapreduce_model, hbase_model, yarn_model are null'
-      },
-      {
-        models: {
-          hdfs_model: {},
-          mapreduce_model: {},
-          hbase_model: null,
-          yarn_model: null
-        },
-        e: {
-          visibleL: total_widgets_count - hbase_widgets_count - yarn_widgets_count - 1,
-          hiddenL: 0
-        },
-        m: 'hbase_model and yarn_model are null'
-      },
-      {
-        models: {
-          hdfs_model: {},
-          mapreduce_model: {},
-          hbase_model: {},
-          yarn_model: null
-        },
-        e: {
-          visibleL: total_widgets_count - yarn_widgets_count - 1,
-          hiddenL: 1
-        },
-        m: 'yarn_model is null'
-      },
-      {
-        models: {
-          hdfs_model: {},
-          mapreduce_model: {},
-          hbase_model: {},
-          yarn_model: {}
-        },
-        e: {
-          visibleL: total_widgets_count - 1,
-          hiddenL: 1
-        },
-        m: 'All models are not null'
-      }
-    ];
-    tests.forEach(function(test) {
-      it(test.m, function() {
-        mainDashboardView.set('hdfs_model', test.models.hdfs_model);
-        mainDashboardView.set('mapreduce_model', test.models.mapreduce_model);
-        mainDashboardView.set('hbase_model', test.models.hbase_model);
-        mainDashboardView.set('yarn_model', test.models.yarn_model);
-        mainDashboardView.setInitPrefObject();
-        expect(mainDashboardView.get('initPrefObject.visible.length')).to.equal(test.e.visibleL);
-        expect(mainDashboardView.get('initPrefObject.hidden.length')).to.equal(test.e.hiddenL);
-      });
-    });
-  });
-
-  describe('#persistKey', function() {
-    App.router.set('loginName', 'tdk');
-    it('Check it', function() {
-      expect(mainDashboardView.get('persistKey')).to.equal('user-pref-tdk-dashboard');
-    });
-  });
+   beforeEach(function() {
+     mainDashboardView = App.MainDashboardView.create();
+   });
 
 
 });
 });