diff options
Diffstat (limited to 'spec/javascripts/image_diff')
5 files changed, 84 insertions, 58 deletions
diff --git a/spec/javascripts/image_diff/helpers/utils_helper_spec.js b/spec/javascripts/image_diff/helpers/utils_helper_spec.js index 70bdf0d3609..6f62ee3f93b 100644 --- a/spec/javascripts/image_diff/helpers/utils_helper_spec.js +++ b/spec/javascripts/image_diff/helpers/utils_helper_spec.js @@ -5,13 +5,7 @@ import ImageBadge from '~/image_diff/image_badge'; import * as mockData from '../mock_data'; describe('utilsHelper', () => { - const { - noteId, - discussionId, - image, - imageProperties, - imageMeta, - } = mockData; + const { noteId, discussionId, image, imageProperties, imageMeta } = mockData; describe('resizeCoordinatesToImageElement', () => { let result; diff --git a/spec/javascripts/image_diff/image_badge_spec.js b/spec/javascripts/image_diff/image_badge_spec.js index ce723e5d23c..2b23dce5d30 100644 --- a/spec/javascripts/image_diff/image_badge_spec.js +++ b/spec/javascripts/image_diff/image_badge_spec.js @@ -10,9 +10,11 @@ describe('ImageBadge', () => { }; it('should save actual property', () => { - const imageBadge = new ImageBadge(Object.assign({}, options, { - actual: imageMeta, - })); + const imageBadge = new ImageBadge( + Object.assign({}, options, { + actual: imageMeta, + }), + ); const { actual } = imageBadge; @@ -23,9 +25,11 @@ describe('ImageBadge', () => { }); it('should save browser property', () => { - const imageBadge = new ImageBadge(Object.assign({}, options, { - browser: imageMeta, - })); + const imageBadge = new ImageBadge( + Object.assign({}, options, { + browser: imageMeta, + }), + ); const { browser } = imageBadge; @@ -79,9 +83,11 @@ describe('ImageBadge', () => { }); it('should generate browser property', () => { - const imageBadge = new ImageBadge(Object.assign({}, options, { - imageEl: document.createElement('img'), - })); + const imageBadge = new ImageBadge( + Object.assign({}, options, { + imageEl: document.createElement('img'), + }), + ); expect(imageDiffHelper.resizeCoordinatesToImageElement).toHaveBeenCalled(); expect(imageBadge.browser).toEqual(true); diff --git a/spec/javascripts/image_diff/image_diff_spec.js b/spec/javascripts/image_diff/image_diff_spec.js index 9a7f288cd6b..21e7b8e2e9b 100644 --- a/spec/javascripts/image_diff/image_diff_spec.js +++ b/spec/javascripts/image_diff/image_diff_spec.js @@ -128,16 +128,6 @@ describe('ImageDiff', () => { }); }); - describe('image loaded', () => { - beforeEach(() => { - spyOn(imageUtility, 'isImageLoaded').and.returnValue(true); - imageDiff = new ImageDiff(element); - imageDiff.imageEl = imageEl; - }); - - it('should renderBadges', () => {}); - }); - describe('image not loaded', () => { beforeEach(() => { spyOn(imageUtility, 'isImageLoaded').and.returnValue(false); diff --git a/spec/javascripts/image_diff/init_discussion_tab_spec.js b/spec/javascripts/image_diff/init_discussion_tab_spec.js index fbc68679c41..7cacc45ab62 100644 --- a/spec/javascripts/image_diff/init_discussion_tab_spec.js +++ b/spec/javascripts/image_diff/init_discussion_tab_spec.js @@ -11,7 +11,7 @@ describe('initDiscussionTab', () => { `); }); - it('should pass canCreateNote as false to initImageDiff', (done) => { + it('should pass canCreateNote as false to initImageDiff', done => { spyOn(imageDiffHelper, 'initImageDiff').and.callFake((diffFileEl, canCreateNote) => { expect(canCreateNote).toEqual(false); done(); @@ -20,11 +20,13 @@ describe('initDiscussionTab', () => { initDiscussionTab(); }); - it('should pass renderCommentBadge as true to initImageDiff', (done) => { - spyOn(imageDiffHelper, 'initImageDiff').and.callFake((diffFileEl, canCreateNote, renderCommentBadge) => { - expect(renderCommentBadge).toEqual(true); - done(); - }); + it('should pass renderCommentBadge as true to initImageDiff', done => { + spyOn(imageDiffHelper, 'initImageDiff').and.callFake( + (diffFileEl, canCreateNote, renderCommentBadge) => { + expect(renderCommentBadge).toEqual(true); + done(); + }, + ); initDiscussionTab(); }); diff --git a/spec/javascripts/image_diff/replaced_image_diff_spec.js b/spec/javascripts/image_diff/replaced_image_diff_spec.js index 49fed323871..62e7c8b6c6a 100644 --- a/spec/javascripts/image_diff/replaced_image_diff_spec.js +++ b/spec/javascripts/image_diff/replaced_image_diff_spec.js @@ -37,16 +37,28 @@ describe('ReplacedImageDiff', () => { function setupImageFrameEls() { replacedImageDiff.imageFrameEls = []; - replacedImageDiff.imageFrameEls[viewTypes.TWO_UP] = element.querySelector('.two-up .js-image-frame'); - replacedImageDiff.imageFrameEls[viewTypes.SWIPE] = element.querySelector('.swipe .js-image-frame'); - replacedImageDiff.imageFrameEls[viewTypes.ONION_SKIN] = element.querySelector('.onion-skin .js-image-frame'); + replacedImageDiff.imageFrameEls[viewTypes.TWO_UP] = element.querySelector( + '.two-up .js-image-frame', + ); + replacedImageDiff.imageFrameEls[viewTypes.SWIPE] = element.querySelector( + '.swipe .js-image-frame', + ); + replacedImageDiff.imageFrameEls[viewTypes.ONION_SKIN] = element.querySelector( + '.onion-skin .js-image-frame', + ); } function setupViewModesEls() { replacedImageDiff.viewModesEls = []; - replacedImageDiff.viewModesEls[viewTypes.TWO_UP] = element.querySelector('.view-modes-menu .two-up'); - replacedImageDiff.viewModesEls[viewTypes.SWIPE] = element.querySelector('.view-modes-menu .swipe'); - replacedImageDiff.viewModesEls[viewTypes.ONION_SKIN] = element.querySelector('.view-modes-menu .onion-skin'); + replacedImageDiff.viewModesEls[viewTypes.TWO_UP] = element.querySelector( + '.view-modes-menu .two-up', + ); + replacedImageDiff.viewModesEls[viewTypes.SWIPE] = element.querySelector( + '.view-modes-menu .swipe', + ); + replacedImageDiff.viewModesEls[viewTypes.ONION_SKIN] = element.querySelector( + '.view-modes-menu .onion-skin', + ); } function setupImageEls() { @@ -75,18 +87,34 @@ describe('ReplacedImageDiff', () => { const { imageFrameEls } = replacedImageDiff; expect(imageFrameEls).toBeDefined(); - expect(imageFrameEls[viewTypes.TWO_UP]).toEqual(element.querySelector('.two-up .js-image-frame')); - expect(imageFrameEls[viewTypes.SWIPE]).toEqual(element.querySelector('.swipe .js-image-frame')); - expect(imageFrameEls[viewTypes.ONION_SKIN]).toEqual(element.querySelector('.onion-skin .js-image-frame')); + expect(imageFrameEls[viewTypes.TWO_UP]).toEqual( + element.querySelector('.two-up .js-image-frame'), + ); + + expect(imageFrameEls[viewTypes.SWIPE]).toEqual( + element.querySelector('.swipe .js-image-frame'), + ); + + expect(imageFrameEls[viewTypes.ONION_SKIN]).toEqual( + element.querySelector('.onion-skin .js-image-frame'), + ); }); it('should set viewModesEls', () => { const { viewModesEls } = replacedImageDiff; expect(viewModesEls).toBeDefined(); - expect(viewModesEls[viewTypes.TWO_UP]).toEqual(element.querySelector('.view-modes-menu .two-up')); - expect(viewModesEls[viewTypes.SWIPE]).toEqual(element.querySelector('.view-modes-menu .swipe')); - expect(viewModesEls[viewTypes.ONION_SKIN]).toEqual(element.querySelector('.view-modes-menu .onion-skin')); + expect(viewModesEls[viewTypes.TWO_UP]).toEqual( + element.querySelector('.view-modes-menu .two-up'), + ); + + expect(viewModesEls[viewTypes.SWIPE]).toEqual( + element.querySelector('.view-modes-menu .swipe'), + ); + + expect(viewModesEls[viewTypes.ONION_SKIN]).toEqual( + element.querySelector('.view-modes-menu .onion-skin'), + ); }); it('should generateImageEls', () => { @@ -147,8 +175,8 @@ describe('ReplacedImageDiff', () => { expect(ImageDiff.prototype.bindEvents).toHaveBeenCalled(); }); - it('should register click eventlistener to 2-up view mode', (done) => { - spyOn(ReplacedImageDiff.prototype, 'changeView').and.callFake((viewMode) => { + it('should register click eventlistener to 2-up view mode', done => { + spyOn(ReplacedImageDiff.prototype, 'changeView').and.callFake(viewMode => { expect(viewMode).toEqual(viewTypes.TWO_UP); done(); }); @@ -157,8 +185,8 @@ describe('ReplacedImageDiff', () => { replacedImageDiff.viewModesEls[viewTypes.TWO_UP].click(); }); - it('should register click eventlistener to swipe view mode', (done) => { - spyOn(ReplacedImageDiff.prototype, 'changeView').and.callFake((viewMode) => { + it('should register click eventlistener to swipe view mode', done => { + spyOn(ReplacedImageDiff.prototype, 'changeView').and.callFake(viewMode => { expect(viewMode).toEqual(viewTypes.SWIPE); done(); }); @@ -167,8 +195,8 @@ describe('ReplacedImageDiff', () => { replacedImageDiff.viewModesEls[viewTypes.SWIPE].click(); }); - it('should register click eventlistener to onion skin view mode', (done) => { - spyOn(ReplacedImageDiff.prototype, 'changeView').and.callFake((viewMode) => { + it('should register click eventlistener to onion skin view mode', done => { + spyOn(ReplacedImageDiff.prototype, 'changeView').and.callFake(viewMode => { expect(viewMode).toEqual(viewTypes.SWIPE); done(); }); @@ -203,11 +231,15 @@ describe('ReplacedImageDiff', () => { }); it('should return imageFrameEl based on currentView', () => { - expect(replacedImageDiff.imageFrameEl).toEqual(element.querySelector('.two-up .js-image-frame')); + expect(replacedImageDiff.imageFrameEl).toEqual( + element.querySelector('.two-up .js-image-frame'), + ); replacedImageDiff.currentView = viewTypes.ONION_SKIN; - expect(replacedImageDiff.imageFrameEl).toEqual(element.querySelector('.onion-skin .js-image-frame')); + expect(replacedImageDiff.imageFrameEl).toEqual( + element.querySelector('.onion-skin .js-image-frame'), + ); }); }); }); @@ -293,7 +325,7 @@ describe('ReplacedImageDiff', () => { setupImageFrameEls(); }); - it('should pass showCommentIndicator normalized indicator values', (done) => { + it('should pass showCommentIndicator normalized indicator values', done => { spyOn(imageDiffHelper, 'showCommentIndicator').and.callFake(() => {}); spyOn(imageDiffHelper, 'resizeCoordinatesToImageElement').and.callFake((imageEl, meta) => { expect(meta.x).toEqual(indicator.x); @@ -305,15 +337,17 @@ describe('ReplacedImageDiff', () => { replacedImageDiff.renderNewView(indicator); }); - it('should call showCommentIndicator', (done) => { + it('should call showCommentIndicator', done => { const normalized = { normalized: true, }; spyOn(imageDiffHelper, 'resizeCoordinatesToImageElement').and.returnValue(normalized); - spyOn(imageDiffHelper, 'showCommentIndicator').and.callFake((imageFrameEl, normalizedIndicator) => { - expect(normalizedIndicator).toEqual(normalized); - done(); - }); + spyOn(imageDiffHelper, 'showCommentIndicator').and.callFake( + (imageFrameEl, normalizedIndicator) => { + expect(normalizedIndicator).toEqual(normalized); + done(); + }, + ); replacedImageDiff.renderNewView(indicator); }); }); |