From 4577bf0aaba1494517e2b41e453a42e8f7c76854 Mon Sep 17 00:00:00 2001 From: Cindy Lu Date: Wed, 20 Jul 2016 15:56:54 -0700 Subject: [PATCH] Cleanup the toastService in *.spec.js files We should not use toastService to test if an API call went through successfully. This is extraneous. This patch was motivated by the fact that we want to remove conf.js, so we are moving the toast config options to toast.service.js. Change-Id: I966fb0d492ae8e9ae70af2882655cd36b4214a4a --- .../keypair/import-keypair.controller.spec.js | 7 +------ .../core/images/actions/create-volume.service.spec.js | 6 +----- .../core/images/actions/create.action.service.spec.js | 10 +--------- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/keypair/import-keypair.controller.spec.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/keypair/import-keypair.controller.spec.js index 8857373aae..a4b04e1547 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/keypair/import-keypair.controller.spec.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/keypair/import-keypair.controller.spec.js @@ -19,7 +19,7 @@ describe('Launch Instance Import Key Pair Controller', function() { - var novaAPI, ctrl, toastService, $q, $rootScope; + var novaAPI, ctrl, $q, $rootScope; var data = { data: { name: 'newKeypair', public_key: '' } }; var modalInstanceMock = { close: angular.noop, @@ -35,7 +35,6 @@ ctrl = $controller('LaunchInstanceImportKeyPairController', { $modalInstance: modalInstanceMock }); - toastService = $injector.get('horizon.framework.widgets.toast.service'); $q = _$q_; $rootScope = _$rootScope_; })); @@ -54,7 +53,6 @@ var deferredSuccess = $q.defer(); spyOn(novaAPI, 'createKeypair').and.returnValue(deferredSuccess.promise); spyOn(modalInstanceMock, 'close'); - spyOn(toastService, 'add').and.callThrough(); ctrl.submit(); @@ -63,9 +61,6 @@ expect(novaAPI.createKeypair).toHaveBeenCalled(); expect(modalInstanceMock.close).toHaveBeenCalled(); - expect(toastService.add).toHaveBeenCalledWith( - 'success', - 'Successfully imported key pair newKeypair.'); }); it('defines a cancel function', function() { diff --git a/openstack_dashboard/static/app/core/images/actions/create-volume.service.spec.js b/openstack_dashboard/static/app/core/images/actions/create-volume.service.spec.js index 4b8c0a7ab3..d969368848 100644 --- a/openstack_dashboard/static/app/core/images/actions/create-volume.service.spec.js +++ b/openstack_dashboard/static/app/core/images/actions/create-volume.service.spec.js @@ -18,7 +18,7 @@ describe('horizon.app.core.images.actions.create-volume.service', function() { - var service, $scope, toast, events, workflow; + var service, $scope, events, workflow; var wizardModalService = { modal: function () { return { @@ -72,7 +72,6 @@ beforeEach(inject(function($injector, _$rootScope_) { $scope = _$rootScope_.$new(); service = $injector.get('horizon.app.core.images.actions.create-volume.service'); - toast = $injector.get('horizon.framework.widgets.toast.service'); events = $injector.get('horizon.app.core.images.events'); workflow = $injector.get('horizon.app.core.images.workflows.create-volume.service'); })); @@ -96,7 +95,6 @@ var volume = { name: 'Test', id: '2' }; spyOn(cinderAPI, 'createVolume').and.callThrough(); - spyOn(toast, 'add').and.callThrough(); spyOn(wizardModalService, 'modal').and.callThrough(); service.initScope($scope); @@ -110,8 +108,6 @@ $scope.$apply(); expect(cinderAPI.createVolume).toHaveBeenCalledWith(volume); - expect(toast.add).toHaveBeenCalledWith('success', 'Volume Test was successfully created.'); - expect(toast.add.calls.count()).toBe(1); }); it('should destroy volume change watcher on exit', function() { diff --git a/openstack_dashboard/static/app/core/images/actions/create.action.service.spec.js b/openstack_dashboard/static/app/core/images/actions/create.action.service.spec.js index 81218849f8..f8875735ba 100644 --- a/openstack_dashboard/static/app/core/images/actions/create.action.service.spec.js +++ b/openstack_dashboard/static/app/core/images/actions/create.action.service.spec.js @@ -54,7 +54,7 @@ } }; - var service, events, $scope, toast, deferredModal, deferredCreate, $q; + var service, events, $scope, deferredModal, deferredCreate, $q; /////////////////////// @@ -72,7 +72,6 @@ $scope = _$rootScope_.$new(); service = $injector.get('horizon.app.core.images.actions.create.service'); events = $injector.get('horizon.app.core.images.events'); - toast = $injector.get('horizon.framework.widgets.toast.service'); $q = _$q_; })); @@ -104,7 +103,6 @@ spyOn($scope, '$emit').and.callThrough(); spyOn(glanceAPI, 'createImage').and.callThrough(); - spyOn(toast, 'add').and.callThrough(); spyOn(wizardModalService, 'modal').and.callThrough(); service.initScope($scope); @@ -119,7 +117,6 @@ expect(glanceAPI.createImage).toHaveBeenCalledWith({ name: 'Test', id: '2', prop1: '11', prop3: '3'}); - expect(toast.add).toHaveBeenCalledWith('success', 'Image Test was successfully created.'); }); it('should raise event even if update meta data fails', function() { @@ -136,7 +133,6 @@ spyOn(glanceAPI, 'createImage').and.callThrough(); spyOn(metadataService, 'editMetadata').and.callFake(failedPromise); spyOn($scope, '$emit').and.callThrough(); - spyOn(toast, 'add').and.callThrough(); service.initScope($scope); service.perform(); @@ -149,8 +145,6 @@ var modalArgs = wizardModalService.modal.calls.argsFor(0)[0]; modalArgs.submit(); $scope.$apply(); - - expect(toast.add.calls.count()).toBe(1); }); it('should destroy the event watchers', function() { @@ -160,7 +154,6 @@ spyOn(wizardModalService, 'modal').and.callThrough(); spyOn(glanceAPI, 'createImage').and.callThrough(); spyOn(metadataService, 'editMetadata').and.callThrough(); - spyOn(toast, 'add').and.callThrough(); service.initScope($scope); service.perform(); @@ -175,7 +168,6 @@ $scope.$apply(); expect(glanceAPI.createImage).toHaveBeenCalledWith({}); - expect(toast.add.calls.count()).toBe(1); }); });