Mark Lenser pushed to branch feature/cmng-psp1-CHANNELMGR-696 at cms-community 
/ hippo-addon-channel-manager


Commits:
4d6acc28 by Mark at 2016-05-30T16:35:44+02:00
CHANNELMGR-696: add tests

- - - - -
6000903d by Mark at 2016-05-30T16:43:22+02:00
CHANNELMGR-696: add test

- - - - -


2 changed files:

- frontend-ng/src/angularjs/channel/sidenav/sidenav.spec.js
- + frontend-ng/src/angularjs/channel/subpage/subpage.service.spec.js


Changes:

=====================================
frontend-ng/src/angularjs/channel/sidenav/sidenav.spec.js
=====================================
--- a/frontend-ng/src/angularjs/channel/sidenav/sidenav.spec.js
+++ b/frontend-ng/src/angularjs/channel/sidenav/sidenav.spec.js
@@ -23,6 +23,7 @@ describe('ChannelSidenav', () => {
   let SiteMapService;
   let ChannelService;
   let HippoIframeService;
+  let SubpageService;
   let parentScope;
   const catalogComponents = [
     { label: 'dummy' },
@@ -31,13 +32,14 @@ describe('ChannelSidenav', () => {
   beforeEach(() => {
     module('hippo-cm');
 
-    inject((_$rootScope_, _$compile_, _ChannelSidenavService_, 
_ChannelService_, _SiteMapService_, _HippoIframeService_) => {
+    inject((_$rootScope_, _$compile_, _ChannelSidenavService_, 
_ChannelService_, _SiteMapService_, _HippoIframeService_, _SubpageService_) => {
       $rootScope = _$rootScope_;
       $compile = _$compile_;
       ChannelSidenavService = _ChannelSidenavService_;
       ChannelService = _ChannelService_;
       SiteMapService = _SiteMapService_;
       HippoIframeService = _HippoIframeService_;
+      SubpageService = _SubpageService_;
     });
 
     spyOn(ChannelService, 'getCatalog').and.returnValue([]);
@@ -46,6 +48,7 @@ describe('ChannelSidenav', () => {
     spyOn(SiteMapService, 'get');
     spyOn(HippoIframeService, 'load');
     spyOn(HippoIframeService, 'getCurrentRenderPathInfo');
+    spyOn(SubpageService, 'showSubpage');
   });
 
   function instantiateController(editMode) {
@@ -117,5 +120,11 @@ describe('ChannelSidenav', () => {
     siteMapItem.renderPathInfo = '/other/path';
     expect(ChannelSidenavCtrl.isActiveSiteMapItem(siteMapItem)).toBe(false);
   });
+
+  it('can show a subpage', () => {
+    const ChannelSidenavCtrl = instantiateController(false);
+    ChannelSidenavCtrl.showSubpage('test');
+    expect(SubpageService.showSubpage).toHaveBeenCalledWith('test');
+  });
 });
 


=====================================
frontend-ng/src/angularjs/channel/subpage/subpage.service.spec.js
=====================================
--- /dev/null
+++ b/frontend-ng/src/angularjs/channel/subpage/subpage.service.spec.js
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 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.
+ */
+
+/* eslint-disable prefer-const */
+
+describe('SubpageService', () => {
+  'use strict';
+
+  let SubpageService;
+
+  beforeEach(() => {
+    module('hippo-cm');
+
+    inject((_SubpageService_) => {
+      SubpageService = _SubpageService_;
+    });
+
+    SubpageService.subpage = {
+      current: 'test',
+    };
+  });
+
+  describe('getSubpage', () => {
+    beforeEach(() => {
+      spyOn(SubpageService, 'getSubpage').and.callThrough();
+    });
+    it('should return this.subpage', () => {
+      expect(SubpageService.getSubpage().current).toBe('test');
+    });
+  });
+
+  describe('showSubpage', () => {
+    it('should show a subpage', () => {
+      SubpageService.showSubpage('new-subpage');
+      expect(SubpageService.subpage.current).toBe('new-subpage');
+    });
+  });
+
+  describe('hideSubpage', () => {
+    it('should hide a subpage', () => {
+      expect(SubpageService.subpage.current).toBe('test');
+      SubpageService.hideSubpage();
+      expect(SubpageService.subpage.current).toBe(undefined);
+    });
+  });
+});



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/885a7a3f7e0d390aaec4c9353deab729c188b16b...6000903ddba5e1c7fb457cbf4f1204b61ca03669
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to