Mark Lenser pushed to branch feature/visual-editing-psp1-CHANELLMGR-919 at cms-community / hippo-addon-channel-manager
Commits: 84cd68cd by Mark at 2016-11-23T11:01:35+01:00 CHANNELMGR-919 add tests - - - - - 1 changed file: - frontend-ng/src/angularjs/channel/sidePanels/rightSidePanel/rightSidePanel.spec.js Changes: ===================================== frontend-ng/src/angularjs/channel/sidePanels/rightSidePanel/rightSidePanel.spec.js ===================================== --- a/frontend-ng/src/angularjs/channel/sidePanels/rightSidePanel/rightSidePanel.spec.js +++ b/frontend-ng/src/angularjs/channel/sidePanels/rightSidePanel/rightSidePanel.spec.js @@ -23,6 +23,7 @@ describe('ChannelRightSidePanel', () => { let CmsService; let ContentService; let HippoIframeService; + let FeedbackService; let $ctrl; let $scope; @@ -78,6 +79,8 @@ describe('ChannelRightSidePanel', () => { ChannelSidePanelService = jasmine.createSpyObj('ChannelSidePanelService', ['initialize', 'isOpen', 'close']); ContentService = jasmine.createSpyObj('ContentService', ['createDraft', 'getDocumentType', 'saveDraft', 'deleteDraft']); + FeedbackService = jasmine.createSpyObj('FeedbackService', ['showErrorResponse']); + CmsService = jasmine.createSpyObj('CmsService', ['publish']); HippoIframeService = jasmine.createSpyObj('HippoIframeService', ['reload']); @@ -91,6 +94,7 @@ describe('ChannelRightSidePanel', () => { CmsService, ContentService, HippoIframeService, + FeedbackService, }, { editMode: false, }); @@ -179,6 +183,43 @@ describe('ChannelRightSidePanel', () => { expect(ContentService.saveDraft).not.toHaveBeenCalled(); }); + it('shows a toast when document save fails', () => { + const savedDoc = { + data: { + reason: 'TEST', + }, + id: '123', + }; + ContentService.saveDraft.and.returnValue($q.reject(savedDoc)); + + $ctrl.doc = testDocument; + $ctrl.form.$pristine = false; + $ctrl.saveDocument(); + + expect(ContentService.saveDraft).toHaveBeenCalledWith(testDocument); + + $rootScope.$apply(); + + expect(FeedbackService.showErrorResponse).toHaveBeenCalledWith(savedDoc, 'ERROR_TEST'); + }); + + it('shows a toast when document save fails and there is no data returned', () => { + const savedDoc = { + id: '123', + }; + ContentService.saveDraft.and.returnValue($q.reject(savedDoc)); + + $ctrl.doc = testDocument; + $ctrl.form.$pristine = false; + $ctrl.saveDocument(); + + expect(ContentService.saveDraft).toHaveBeenCalledWith(testDocument); + + $rootScope.$apply(); + + expect(FeedbackService.showErrorResponse).toHaveBeenCalledWith(savedDoc, 'ERROR_UNABLE_TO_SAVE'); + }); + it('views the full content by saving changes, closing the panel and publishing a view-content event', () => { $ctrl.doc = testDocument; ContentService.saveDraft.and.returnValue($q.resolve(testDocument)); View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/84cd68cd0a5f48b2ec7a079f5115a03c6c62158d
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn