Mark Lenser pushed to branch feature/visual-editing-psp1-CHANNELMGR-843 at 
cms-community / hippo-addon-channel-manager


Commits:
8161d1ac by Mark at 2016-09-26T16:37:19+02:00
CHANNELMGR-843 fix tests

- - - - -


2 changed files:

- frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.fixture.html
- frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.spec.js


Changes:

=====================================
frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.fixture.html
=====================================
--- a/frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.fixture.html
+++ b/frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.fixture.html
@@ -14,11 +14,13 @@
   ~ limitations under the License.
   -->
 
-<div id="test-hippo-iframe">
-  <div class="channel-iframe-base" style="overflow: auto">
-    <div class="channel-iframe-canvas">
-      <div class="channel-iframe-sheet cm-scale">
-        <div class="channel-iframe-scroll-x">
+<div id="test-hippo-iframe-wrapper" class="channel-iframe-wrapper">
+  <div id="test-hippo-iframe">
+    <div class="channel-iframe-base" style="overflow: auto">
+      <div class="channel-iframe-canvas">
+        <div class="channel-iframe-sheet cm-scale">
+          <div class="channel-iframe-scroll-x">
+          </div>
         </div>
       </div>
     </div>


=====================================
frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.spec.js
=====================================
--- a/frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.spec.js
+++ b/frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.spec.js
@@ -19,6 +19,7 @@ describe('ScalingService', () => {
 
   let ScalingService;
   let iframeJQueryElement;
+  let iframeWrapper;
   let baseJQueryElement;
   let canvasJQueryElement;
   let elementsToScale;
@@ -32,11 +33,13 @@ describe('ScalingService', () => {
 
     
jasmine.getFixtures().load('channel/hippoIframe/scaling.service.fixture.html');
 
+    iframeWrapper = $j('.channel-iframe-wrapper');
     baseJQueryElement = $j('.channel-iframe-base');
     canvasJQueryElement = $j('.channel-iframe-canvas');
     elementsToScale = jasmine.createSpyObj('elementsToScale', ['velocity', 
'css', 'scrollTop', 'hasClass', 'removeClass', 'addClass']);
 
-    iframeJQueryElement = jasmine.createSpyObj('iframeJQueryElement', ['find', 
'css', 'velocity', 'is']);
+    iframeJQueryElement = jasmine.createSpyObj('iframeJQueryElement', 
['parent', 'find', 'css', 'velocity', 'is']);
+    iframeJQueryElement.parent.and.callFake(() => 
$j('#test-hippo-iframe-wrapper'));
     iframeJQueryElement.find.and.callFake((selector) => {
       if (selector === '.cm-scale') {
         return elementsToScale;
@@ -45,6 +48,9 @@ describe('ScalingService', () => {
     });
     iframeJQueryElement.css.and.callFake(() => '0');
     iframeJQueryElement.is.and.returnValue(true);
+
+
+    iframeWrapper.width(400);
   });
 
   afterEach(() => {
@@ -55,7 +61,6 @@ describe('ScalingService', () => {
   it('should initialize using the default values', () => {
     ScalingService.init(iframeJQueryElement);
 
-    expect(elementsToScale.css).not.toHaveBeenCalled();
     expect(ScalingService.getScaleFactor()).toEqual(1.0);
   });
 
@@ -82,15 +87,15 @@ describe('ScalingService', () => {
   });
 
   it('should change the scaling factor instantly when the window is resized', 
() => {
-    canvasJQueryElement.width(200);
+    canvasJQueryElement.width(400);
     ScalingService.init(iframeJQueryElement);
     ScalingService.setPushWidth('left', 100);
-    ScalingService.scaleFactor = 0.75; // fake different scaling factor so the 
effect of the window resize is testable
+    ScalingService.scaleFactor = 0.1; // fake different scaling factor so the 
effect of the window resize is testable
 
     $j(window).resize();
 
-    expect(elementsToScale.css).toHaveBeenCalledWith('transform', 
'scale(0.5)');
-    expect(ScalingService.getScaleFactor()).toEqual(0.5);
+    expect(elementsToScale.css).toHaveBeenCalledWith('transform', 
'scale(0.75)');
+    expect(ScalingService.getScaleFactor()).toEqual(0.75);
   });
 
   it('should update the scroll position instantly while scaling', () => {



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/8161d1acaadb9346143fb5379de60f7f089b148c
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to