Mathijs den Burger pushed to branch feature/CHANNELMGR-1660 at cms-community / hippo-addon-channel-manager
Commits: cc688d85 by Mathijs den Burger at 2018-01-15T10:28:15+01:00 CHANNELMGR-1660 Remove onOpen and onClose tests from SidePanelService The onOpen and onClose callbacks were only used by the right side-panel. They are no longer needed because ui-router state changes are now used to open and close the right side-panel. Hence the tests for onOpen and onClose can be removed too. - - - - - c61c40af by Mathijs den Burger at 2018-01-15T10:43:42+01:00 CHANNELMGR-1660 Add tests for RightSidePanelService - - - - - 3 changed files: - + frontend-ng/src/app/channel/sidePanels/rightSidePanel/rightSidePanel.service.spec.js - frontend-ng/src/app/channel/sidePanels/sidePanel.service.js - frontend-ng/src/app/channel/sidePanels/sidePanel.service.spec.js Changes: ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/rightSidePanel.service.spec.js ===================================== --- /dev/null +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/rightSidePanel.service.spec.js @@ -0,0 +1,49 @@ +/* + * Copyright 2018 Hippo B.V. (http://www.onehippo.com) + * + * Licensed 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. + */ + +describe('RightSidePanelService', () => { + let RightSidePanelService; + + beforeEach(() => { + angular.mock.module('hippo-cm'); + + inject((_RightSidePanelService_) => { + RightSidePanelService = _RightSidePanelService_; + }); + }); + + it('initializes correctly', () => { + expect(RightSidePanelService.isLoading()).toEqual(false); + expect(RightSidePanelService.getTitle()).toEqual(''); + }); + + it('manages loading', () => { + RightSidePanelService.startLoading(); + expect(RightSidePanelService.isLoading()).toEqual(true); + + RightSidePanelService.stopLoading(); + expect(RightSidePanelService.isLoading()).toEqual(false); + }); + + it('manages the title', () => { + RightSidePanelService.setTitle('test title'); + expect(RightSidePanelService.getTitle()).toEqual('test title'); + + RightSidePanelService.clearTitle(); + expect(RightSidePanelService.getTitle()).toEqual(''); + }); +}); + ===================================== frontend-ng/src/app/channel/sidePanels/sidePanel.service.js ===================================== --- a/frontend-ng/src/app/channel/sidePanels/sidePanel.service.js +++ b/frontend-ng/src/app/channel/sidePanels/sidePanel.service.js @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 Hippo B.V. (http://www.onehippo.com) + * Copyright 2016-2018 Hippo B.V. (http://www.onehippo.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. ===================================== frontend-ng/src/app/channel/sidePanels/sidePanel.service.spec.js ===================================== --- a/frontend-ng/src/app/channel/sidePanels/sidePanel.service.spec.js +++ b/frontend-ng/src/app/channel/sidePanels/sidePanel.service.spec.js @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 Hippo B.V. (http://www.onehippo.com) + * Copyright 2016-2018 Hippo B.V. (http://www.onehippo.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -xdescribe('SidePanelService', () => { +describe('SidePanelService', () => { let SidePanelService; let $q; let $rootScope; @@ -106,38 +106,6 @@ xdescribe('SidePanelService', () => { $rootScope.$digest(); }); - it('calls the onCloseCallback before closing a side panel', (done) => { - const element = angular.element('<div></div>'); - const onClose = jasmine.createSpy('onClose'); - SidePanelService.initialize('left', element, null, onClose); - - leftSidePanel.isOpen.and.returnValue(true); - onClose.and.returnValue($q.resolve()); - - SidePanelService.close('left').then(() => { - expect(onClose).toHaveBeenCalled(); - expect(leftSidePanel.close).toHaveBeenCalled(); - done(); - }); - $rootScope.$digest(); - }); - - it('does not close a side panel if its onCloseCallback fails', (done) => { - const element = angular.element('<div></div>'); - const onClose = jasmine.createSpy('onClose'); - SidePanelService.initialize('left', element, null, onClose); - - leftSidePanel.isOpen.and.returnValue(true); - onClose.and.returnValue($q.reject()); - - SidePanelService.close('left').catch(() => { - expect(onClose).toHaveBeenCalled(); - expect(leftSidePanel.close).not.toHaveBeenCalled(); - done(); - }); - $rootScope.$digest(); - }); - it('forwards the open call to the mdSidenav service', () => { const element = angular.element('<div></div>'); SidePanelService.initialize('left', element); @@ -152,36 +120,6 @@ xdescribe('SidePanelService', () => { }).not.toThrow(jasmine.any(Error)); }); - it('calls the onOpen callback when specified', () => { - const element = angular.element('<div md-component-id="left"></div>'); - const onOpen = jasmine.createSpy('onOpen'); - - SidePanelService.initialize('left', element, onOpen); - - SidePanelService.open('left'); - expect(onOpen).toHaveBeenCalled(); - }); - - it('calls the onOpen callback when the side-panel is already open', () => { - const element = angular.element('<div md-component-id="left"></div>'); - const onOpen = jasmine.createSpy('onOpen'); - - SidePanelService.initialize('left', element, onOpen); - - leftSidePanel.isOpen.and.returnValue(true); - SidePanelService.open('left'); - - expect(onOpen).toHaveBeenCalled(); - }); - - it('opens without errors when the onOpen callback is omitted', () => { - const element = angular.element('<div md-component-id="left"></div>'); - SidePanelService.initialize('left', element); - expect(() => { - SidePanelService.open('left'); - }).not.toThrow(jasmine.any(Error)); - }); - it('syncs the iframe once the side-panel has been opened and closed', () => { const element = angular.element('<div></div>'); SidePanelService.initialize('left', element); View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/ebc97328d0aef56232367b5dd87bd1f616f555be...c61c40aff65a723e1b731ee298b129c3343df4fa --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/ebc97328d0aef56232367b5dd87bd1f616f555be...c61c40aff65a723e1b731ee298b129c3343df4fa You're receiving this email because of your account on code.onehippo.org.
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn