You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2019/02/06 10:59:16 UTC
[ambari] branch trunk updated: AMBARI-25144. Cover config history
controller with unit tests
This is an automated email from the ASF dual-hosted git repository.
akovalenko 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 d17de75 AMBARI-25144. Cover config history controller with unit tests
d17de75 is described below
commit d17de751d44e5819f1bc30bc82f06db059588561
Author: Aleksandr Kovalenko <ak...@apache.org>
AuthorDate: Tue Feb 5 19:37:04 2019 +0200
AMBARI-25144. Cover config history controller with unit tests
---
.../main/dashboard/config_history_controller.js | 8 +-
.../dashboard/config_history_controller_test.js | 97 ++++++++++++++++++++++
2 files changed, 101 insertions(+), 4 deletions(-)
diff --git a/ambari-web/app/controllers/main/dashboard/config_history_controller.js b/ambari-web/app/controllers/main/dashboard/config_history_controller.js
index ffef7e4..3383b61 100644
--- a/ambari-web/app/controllers/main/dashboard/config_history_controller.js
+++ b/ambari-web/app/controllers/main/dashboard/config_history_controller.js
@@ -178,21 +178,21 @@ App.MainConfigHistoryController = Em.ArrayController.extend(App.TableServerMixin
var savedSortConditions = App.db.getSortingStatuses(this.get('name')) || [],
sortProperties = this.get('sortProps'),
sortParams = [];
-
+
savedSortConditions.forEach(function (sort) {
var property = sortProperties.findProperty('name', sort.name);
if (property && (sort.status === 'sorting_asc' || sort.status === 'sorting_desc')) {
property.value = sort.status.replace('sorting_', '');
property.type = 'SORT';
- if (property.name == 'serviceVersion'){
+ if (property.name === 'serviceVersion') {
property.key = "service_name." + sort.status.replace('sorting_', '') + ",service_config_version";
property.value = "desc";
}
- if (property.name == 'configGroup'){
+ if (property.name === 'configGroup') {
property.key = "group_name." + sort.status.replace('sorting_', '') + ",service_config_version";
property.value = "desc";
}
-
+
sortParams.push(property);
}
});
diff --git a/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js b/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
index 24c1bbd..2a9f6a9 100644
--- a/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
+++ b/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
@@ -158,5 +158,102 @@ describe('MainConfigHistoryController', function () {
expect(App.StompClient.removeHandler.calledWith('/events/configs', 'history')).to.be.true;
});
});
+
+ describe('#colPropAssoc', function() {
+
+ it('should return associations', function() {
+ expect(controller.get('colPropAssoc')[1]).to.be.equal('serviceVersion');
+ expect(controller.get('colPropAssoc')[2]).to.be.equal('configGroup');
+ expect(controller.get('colPropAssoc')[3]).to.be.equal('createTime');
+ expect(controller.get('colPropAssoc')[4]).to.be.equal('author');
+ expect(controller.get('colPropAssoc')[5]).to.be.equal('notes');
+ });
+ });
+
+ describe('#getSortProps', function() {
+ beforeEach(function() {
+ sinon.stub(App.db, 'getSortingStatuses').returns([
+ {
+ name: 'serviceVersion',
+ status: 'sorting_asc'
+ },
+ {
+ name: 'configGroup',
+ status: 'sorting_desc'
+ },
+ {
+ name: 's3',
+ status: 'sorting_asc'
+ }
+ ]);
+ });
+ afterEach(function() {
+ App.db.getSortingStatuses.restore();
+ });
+
+ it('should return sort properties', function() {
+ controller.set('sortProps', [
+ {
+ name: 'serviceVersion'
+ },
+ {
+ name: 'configGroup'
+ },
+ {
+ name: 's3'
+ }
+ ]);
+ expect(controller.getSortProps()).to.be.eql([
+ {
+ "key": "service_name.asc,service_config_version",
+ "name": "serviceVersion",
+ "type": "SORT",
+ "value": "desc"
+
+ },
+ {
+ "key": "group_name.desc,service_config_version",
+ "name": "configGroup",
+ "type": "SORT",
+ "value": "desc"
+ },
+ {
+ "name": "s3",
+ "type": "SORT",
+ "value": "asc"
+ }
+ ]);
+ });
+ });
+
+ describe('#getSearchBoxSuggestions', function() {
+
+ beforeEach(function() {
+ App.ajax.send.restore();
+ sinon.stub(App.ajax, 'send').returns({
+ done: function(callback) {
+ callback({items: [{'name1': '1'}]});
+ return {
+ fail: Em.clb
+ }
+ }
+ });
+ });
+
+ it('request should be sent', function() {
+ controller.set('filterProps', [{
+ name: 'name1',
+ key: 'key1'
+ }]);
+ controller.getSearchBoxSuggestions('name1');
+ expect(testHelpers.findAjaxRequest('name', 'service.serviceConfigVersions.get.suggestions')[0]).to.be.eql({
+ name: 'service.serviceConfigVersions.get.suggestions',
+ sender: controller,
+ data: {
+ 'key': 'key1'
+ }
+ });
+ });
+ });
});