http://git-wip-us.apache.org/repos/asf/ambari/blob/76dd478e/ambari-web/test/utils/host_progress_popup_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/host_progress_popup_test.js b/ambari-web/test/utils/host_progress_popup_test.js index 5a7ab02..1b7efb3 100644 --- a/ambari-web/test/utils/host_progress_popup_test.js +++ b/ambari-web/test/utils/host_progress_popup_test.js @@ -476,4 +476,116 @@ describe('App.HostPopup', function () { }); }); + describe('#_getHostsMap', function () { + + Em.A([ + { + inputData: [ + {name: 's1', hostsMap: {h1: {}, h2: {}}}, + {name: 's2'} + ], + isBackgroundOperations: true, + currentServiceId: null, + serviceName: 's1', + m: '`currentServiceId` is null, `serviceName` exists, `isBackgroundOperations` true, `hostsMap` exists', + e: {h1: {}, h2: {}} + }, + { + inputData: [ + {name: 's1', hosts: [ + {name: 'h1'}, + {name: 'h2'} + ]}, + {name: 's2'} + ], + isBackgroundOperations: true, + currentServiceId: null, + serviceName: 's1', + m: '`currentServiceId` is null, `serviceName` exists, `isBackgroundOperations` true, `hosts` exists', + e: {h1: {name: 'h1'}, h2: {name: 'h2'}} + }, + { + inputData: [ + {id: 1, hostsMap: {h1: {}, h2: {}}}, + {id: 2} + ], + isBackgroundOperations: true, + currentServiceId: 1, + serviceName: 's1', + m: '`currentServiceId` is 1, `serviceName` exists, `isBackgroundOperations` true, `hostsMap` exists', + e: {h1: {}, h2: {}} + }, + { + inputData: [ + {id: 1, hosts: [ + {name: 'h1'}, + {name: 'h2'} + ]}, + {id: 2} + ], + isBackgroundOperations: true, + currentServiceId: 1, + serviceName: 's1', + m: '`currentServiceId` is 1, `serviceName` exists, `isBackgroundOperations` true, `hosts` exists', + e: {h1: {name: 'h1'}, h2: {name: 'h2'}} + }, + + { + inputData: [ + {name: 's1', hostsMap: {h1: {}, h2: {}}}, + {name: 's2'} + ], + isBackgroundOperations: false, + currentServiceId: null, + serviceName: 's1', + m: '`currentServiceId` is null, `serviceName` exists, `isBackgroundOperations` false, `hostsMap` exists', + e: {h1: {}, h2: {}} + }, + { + inputData: [ + {name: 's1', hosts: [ + {name: 'h1'}, + {name: 'h2'} + ]}, + {name: 's2'} + ], + isBackgroundOperations: false, + currentServiceId: null, + serviceName: 's1', + m: '`currentServiceId` is null, `serviceName` exists, `isBackgroundOperations` false, `hosts` exists', + e: {h1: {name: 'h1'}, h2: {name: 'h2'}} + }, + { + inputData: [ + {name: 's1', hostsMap: {h1: {}, h2: {}}} + ], + isBackgroundOperations: false, + currentServiceId: 1, + serviceName: 's1', + m: '`currentServiceId` is 1, `serviceName` exists, `isBackgroundOperations` false, `hostsMap` exists', + e: {h1: {}, h2: {}} + }, + { + inputData: [ + {name: 's1', hostsMap: {h1: {}, h2: {}}} + ], + isBackgroundOperations: false, + currentServiceId: 1, + serviceName: 's1', + m: '`currentServiceId` is 1, `serviceName` exists, `isBackgroundOperations` false, `hosts` exists', + e: {h1: {}, h2: {}} + } + ]).forEach(function (test) { + + it(test.m, function () { + App.HostPopup.setProperties(test); + expect(App.HostPopup._getHostsMap()).to.eql(test.e); + }); + + }); + + }); + + + });
http://git-wip-us.apache.org/repos/asf/ambari/blob/76dd478e/ambari-web/test/views/common/host_progress_popup_body_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/host_progress_popup_body_view_test.js b/ambari-web/test/views/common/host_progress_popup_body_view_test.js new file mode 100644 index 0000000..8642d9b --- /dev/null +++ b/ambari-web/test/views/common/host_progress_popup_body_view_test.js @@ -0,0 +1,58 @@ +/** + * 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'); +var view; + +describe('App.HostProgressPopupBodyView', function () { + + beforeEach(function () { + view = App.HostProgressPopupBodyView.create({ + controller: Em.Object.create({ + dataSourceController: Em.Object.create({}) + }) + }); + }); + + describe('#switchLevel', function () { + + var map = App.HostProgressPopupBodyView.create().get('customControllersSwitchLevelMap'); + + Object.keys(map).forEach(function (controllerName) { + var methodName = map [controllerName]; + var levelName = 'REQUESTS_LIST'; + + beforeEach(function () { + sinon.stub(view, methodName, Em.K); + }); + + afterEach(function () { + view[methodName].restore(); + }); + + it('should call ' + methodName, function () { + view.set('controller.dataSourceController.name', controllerName); + view.switchLevel(levelName); + expect(view[methodName].args[0]).to.eql([levelName]); + }); + + }); + + }); + +}); \ No newline at end of file