summaryrefslogtreecommitdiff
path: root/spec/frontend/image_diff/replaced_image_diff_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/image_diff/replaced_image_diff_spec.js')
-rw-r--r--spec/frontend/image_diff/replaced_image_diff_spec.js64
1 files changed, 34 insertions, 30 deletions
diff --git a/spec/frontend/image_diff/replaced_image_diff_spec.js b/spec/frontend/image_diff/replaced_image_diff_spec.js
index cc4a2530fc4..2b401fc46bf 100644
--- a/spec/frontend/image_diff/replaced_image_diff_spec.js
+++ b/spec/frontend/image_diff/replaced_image_diff_spec.js
@@ -176,34 +176,36 @@ describe('ReplacedImageDiff', () => {
expect(ImageDiff.prototype.bindEvents).toHaveBeenCalled();
});
- it('should register click eventlistener to 2-up view mode', (done) => {
- jest.spyOn(ReplacedImageDiff.prototype, 'changeView').mockImplementation((viewMode) => {
- expect(viewMode).toEqual(viewTypes.TWO_UP);
- done();
- });
+ it('should register click eventlistener to 2-up view mode', () => {
+ const changeViewSpy = jest
+ .spyOn(ReplacedImageDiff.prototype, 'changeView')
+ .mockImplementation(() => {});
replacedImageDiff.bindEvents();
replacedImageDiff.viewModesEls[viewTypes.TWO_UP].click();
+
+ expect(changeViewSpy).toHaveBeenCalledWith(viewTypes.TWO_UP, expect.any(Object));
});
- it('should register click eventlistener to swipe view mode', (done) => {
- jest.spyOn(ReplacedImageDiff.prototype, 'changeView').mockImplementation((viewMode) => {
- expect(viewMode).toEqual(viewTypes.SWIPE);
- done();
- });
+ it('should register click eventlistener to swipe view mode', () => {
+ const changeViewSpy = jest
+ .spyOn(ReplacedImageDiff.prototype, 'changeView')
+ .mockImplementation(() => {});
replacedImageDiff.bindEvents();
replacedImageDiff.viewModesEls[viewTypes.SWIPE].click();
+
+ expect(changeViewSpy).toHaveBeenCalledWith(viewTypes.SWIPE, expect.any(Object));
});
- it('should register click eventlistener to onion skin view mode', (done) => {
- jest.spyOn(ReplacedImageDiff.prototype, 'changeView').mockImplementation((viewMode) => {
- expect(viewMode).toEqual(viewTypes.SWIPE);
- done();
- });
+ it('should register click eventlistener to onion skin view mode', () => {
+ const changeViewSpy = jest
+ .spyOn(ReplacedImageDiff.prototype, 'changeView')
+ .mockImplementation(() => {});
replacedImageDiff.bindEvents();
replacedImageDiff.viewModesEls[viewTypes.SWIPE].click();
+ expect(changeViewSpy).toHaveBeenCalledWith(viewTypes.SWIPE, expect.any(Object));
});
});
@@ -325,32 +327,34 @@ describe('ReplacedImageDiff', () => {
setupImageFrameEls();
});
- it('should pass showCommentIndicator normalized indicator values', (done) => {
+ it('should pass showCommentIndicator normalized indicator values', () => {
jest.spyOn(imageDiffHelper, 'showCommentIndicator').mockImplementation(() => {});
- jest
+ const resizeCoordinatesToImageElementSpy = jest
.spyOn(imageDiffHelper, 'resizeCoordinatesToImageElement')
- .mockImplementation((imageEl, meta) => {
- expect(meta.x).toEqual(indicator.x);
- expect(meta.y).toEqual(indicator.y);
- expect(meta.width).toEqual(indicator.image.width);
- expect(meta.height).toEqual(indicator.image.height);
- done();
- });
+ .mockImplementation(() => {});
+
replacedImageDiff.renderNewView(indicator);
+
+ expect(resizeCoordinatesToImageElementSpy).toHaveBeenCalledWith(undefined, {
+ x: indicator.x,
+ y: indicator.y,
+ width: indicator.image.width,
+ height: indicator.image.height,
+ });
});
- it('should call showCommentIndicator', (done) => {
+ it('should call showCommentIndicator', () => {
const normalized = {
normalized: true,
};
jest.spyOn(imageDiffHelper, 'resizeCoordinatesToImageElement').mockReturnValue(normalized);
- jest
+ const showCommentIndicatorSpy = jest
.spyOn(imageDiffHelper, 'showCommentIndicator')
- .mockImplementation((imageFrameEl, normalizedIndicator) => {
- expect(normalizedIndicator).toEqual(normalized);
- done();
- });
+ .mockImplementation(() => {});
+
replacedImageDiff.renderNewView(indicator);
+
+ expect(showCommentIndicatorSpy).toHaveBeenCalledWith(undefined, normalized);
});
});
});