This is an automated email from the ASF dual-hosted git repository.

alexantonenko pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 176b6d2  AMBARI-25132. Cover metric view
     new 0b2dd28  Merge pull request #2793 from hiveww/AMBARI-25132-trunk
176b6d2 is described below

commit 176b6d285cb2f82590d6178aff3a8f1b24a82a3e
Author: Alex Antonenko <aantone...@hortonworks.com>
AuthorDate: Tue Jan 29 16:33:22 2019 +0300

    AMBARI-25132. Cover metric view
---
 ambari-web/app/assets/test/tests.js         |  1 +
 ambari-web/test/views/common/metric_test.js | 77 +++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)

diff --git a/ambari-web/app/assets/test/tests.js 
b/ambari-web/app/assets/test/tests.js
index d42fbfb..f2fcb49 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -280,6 +280,7 @@ var files = [
   'test/views/common/assign_master_components_view_test',
   'test/views/common/filter_combo_cleanable_test',
   'test/views/common/filter_view_test',
+  'test/views/common/metric_test',
   'test/views/common/pagination_view_test',
   'test/views/common/table_view_test',
   'test/views/common/quick_link_view_test',
diff --git a/ambari-web/test/views/common/metric_test.js 
b/ambari-web/test/views/common/metric_test.js
new file mode 100644
index 0000000..7267e7a
--- /dev/null
+++ b/ambari-web/test/views/common/metric_test.js
@@ -0,0 +1,77 @@
+/**
+ * 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');
+
+describe('App.MetricFilteringWidget', function () {
+  var view;
+  beforeEach(function () {
+    view = App.MetricFilteringWidget.create({
+      controller: Em.Object.create({})
+    });
+  });
+
+  describe('#chosenMetrics', function () {
+    it('should return array with chosenMetric if it is provided', function () {
+      var chosenMetric = Em.Object.create({ label:Em.I18n.t('metric.default'), 
value:null});
+      view.set('chosenMetric', chosenMetric);
+      expect(view.get('chosenMetrics')).to.be.eql([chosenMetric]);
+    });
+
+    it('should return array with metrics if bo chosen metric', function () {
+      expect(view.get('chosenMetrics')).to.be.eql(view.get('defaultMetrics'));
+    });
+  });
+
+  describe('#defaultMetrics', function () {
+    it('should return mapped not null metrics values', function () {
+      expect(view.get('defaultMetrics')).to.be.eql(["cpu", "memory", 
"network", "io"]);
+    });
+  });
+
+  describe('#bindToController', function () {
+    it('should set metricWidget property of controller to current context', 
function () {
+      view.bindToController();
+      expect(view.get('controller').get('metricWidget')).to.be.eql(view);
+    });
+  });
+
+  describe('#toggleMore', function () {
+    it('should toggle showMore property', function () {
+      view.set('showMore', 4);
+      view.toggleMore();
+      expect(view.get('showMore')).to.be.equal(-3);
+    });
+  });
+
+  describe('#init', function () {
+    it('should call bindToController method', function () {
+      sinon.stub(view, 'bindToController');
+      view.init();
+      expect(view.bindToController.calledOnce).to.be.true;
+      view.bindToController.restore();
+    });
+  });
+
+  describe('#activate', function () {
+    it('should set chosenMetric', function () {
+      view.activate({context: 5});
+      expect(view.get('chosenMetric')).to.be.equal(5);
+    });
+  });
+});
\ No newline at end of file

Reply via email to