AMBARI-13453. Fix UI unit tests for admin-view
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/88175691 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/88175691 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/88175691 Branch: refs/heads/branch-dev-patch-upgrade Commit: 88175691e6d414ccca6d07fb33cf7412419b913d Parents: 8bb2b14 Author: Alex Antonenko <[email protected]> Authored: Fri Oct 16 16:34:58 2015 +0300 Committer: Alex Antonenko <[email protected]> Committed: Fri Oct 16 16:39:57 2015 +0300 ---------------------------------------------------------------------- .../unit/controllers/CreateViewInstanceCtrl.js | 14 +++++++++++++- .../test/unit/controllers/mainCtrl_test.js | 17 +++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/88175691/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/CreateViewInstanceCtrl.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/CreateViewInstanceCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/CreateViewInstanceCtrl.js index cd71d11..35ddc16 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/CreateViewInstanceCtrl.js +++ b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/CreateViewInstanceCtrl.js @@ -53,6 +53,7 @@ describe('#CreateViewInstanceCtrl', function () { } }; $httpBackend.flush(); + scope.instance = {}; scope.save(); expect(View.createInstance).toHaveBeenCalled(); }); @@ -63,11 +64,22 @@ describe('#CreateViewInstanceCtrl', function () { $dirty: true } }; + scope.instance = {}; scope.version = '1.0.0'; $httpBackend.expectGET('template/modal/backdrop.html'); $httpBackend.expectGET('template/modal/window.html'); + $httpBackend.whenGET(/\/api\/v1\/clusters\?_=\d+/).respond(200, { + "items" : [ + { + "Clusters" : { + "cluster_name" : "c1", + "version" : "HDP-2.2" + } + } + ] + }); scope.$digest(); $httpBackend.flush(); chai.expect(scope.view.ViewVersionInfo.parameters[0].value).to.equal('d'); }); -}); \ No newline at end of file +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/88175691/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/mainCtrl_test.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/mainCtrl_test.js b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/mainCtrl_test.js index 0ba01a3..8d748d2 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/mainCtrl_test.js +++ b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/mainCtrl_test.js @@ -39,6 +39,15 @@ describe('#Auth', function () { }); $window = _$window_; $httpBackend = _$httpBackend_; + var re = /api\/v1\/services\/AMBARI\/components\/AMBARI_SERVER.+/; + $httpBackend.whenGET(re).respond(200, { + RootServiceComponents: { + component_version: 2.2, + properties: { + 'user.inactivity.timeout.default': 20 + } + } + }); $httpBackend.whenGET(/\/api\/v1\/logout\?_=\d+/).respond(200,{message: "successfully logged out"}); $httpBackend.whenGET(/\/api\/v1\/views.+/) .respond(200,{ @@ -95,7 +104,11 @@ describe('#Auth', function () { it('should reset window.location and ambari localstorage', function () { scope.signOut(); - chai.expect($window.location.pathname).to.be.empty; + + runs(function() { + chai.expect($window.location.pathname).to.be.empty; + }); + var data = JSON.parse(localStorage.ambari); chai.expect(data.app.authenticated).to.equal(undefined); chai.expect(data.app.loginName).to.equal(undefined); @@ -110,4 +123,4 @@ describe('#Auth', function () { chai.expect(scope.viewInstances[0].instance_name).to.equal('VisibleInstance'); }); }); -}); \ No newline at end of file +});
