Commit 4510938a authored by Denys Mishunov's avatar Denys Mishunov

Merge branch 'himkp-jest-image-diffs' into 'master'

Migrate spec/javascripts/image_diff tests to Jest

Closes #194239

See merge request gitlab-org/gitlab!31359
parents aa0e62f3 239c595f
...@@ -15,7 +15,7 @@ export function createImageBadge(noteId, { x, y }, classNames = []) { ...@@ -15,7 +15,7 @@ export function createImageBadge(noteId, { x, y }, classNames = []) {
export function addImageBadge(containerEl, { coordinate, badgeText, noteId }) { export function addImageBadge(containerEl, { coordinate, badgeText, noteId }) {
const buttonEl = createImageBadge(noteId, coordinate, ['badge', 'badge-pill']); const buttonEl = createImageBadge(noteId, coordinate, ['badge', 'badge-pill']);
buttonEl.innerText = badgeText; buttonEl.textContent = badgeText;
containerEl.appendChild(buttonEl); containerEl.appendChild(buttonEl);
} }
...@@ -32,6 +32,6 @@ export function addAvatarBadge(el, event) { ...@@ -32,6 +32,6 @@ export function addAvatarBadge(el, event) {
// Add badge to new comment // Add badge to new comment
const avatarBadgeEl = el.querySelector(`#${noteId} .badge`); const avatarBadgeEl = el.querySelector(`#${noteId} .badge`);
avatarBadgeEl.innerText = badgeNumber; avatarBadgeEl.textContent = badgeNumber;
avatarBadgeEl.classList.remove('hidden'); avatarBadgeEl.classList.remove('hidden');
} }
...@@ -11,12 +11,12 @@ export function setPositionDataAttribute(el, options) { ...@@ -11,12 +11,12 @@ export function setPositionDataAttribute(el, options) {
export function updateDiscussionAvatarBadgeNumber(discussionEl, newBadgeNumber) { export function updateDiscussionAvatarBadgeNumber(discussionEl, newBadgeNumber) {
const avatarBadgeEl = discussionEl.querySelector('.image-diff-avatar-link .badge'); const avatarBadgeEl = discussionEl.querySelector('.image-diff-avatar-link .badge');
avatarBadgeEl.innerText = newBadgeNumber; avatarBadgeEl.textContent = newBadgeNumber;
} }
export function updateDiscussionBadgeNumber(discussionEl, newBadgeNumber) { export function updateDiscussionBadgeNumber(discussionEl, newBadgeNumber) {
const discussionBadgeEl = discussionEl.querySelector('.badge'); const discussionBadgeEl = discussionEl.querySelector('.badge');
discussionBadgeEl.innerText = newBadgeNumber; discussionBadgeEl.textContent = newBadgeNumber;
} }
export function toggleCollapsed(event) { export function toggleCollapsed(event) {
......
...@@ -128,7 +128,7 @@ export default class ImageDiff { ...@@ -128,7 +128,7 @@ export default class ImageDiff {
const updatedBadgeNumber = index; const updatedBadgeNumber = index;
const discussionEl = this.el.querySelector(`#discussion_${discussionId}`); const discussionEl = this.el.querySelector(`#discussion_${discussionId}`);
imageBadgeEls[index].innerText = updatedBadgeNumber; imageBadgeEls[index].textContent = updatedBadgeNumber;
imageDiffHelper.updateDiscussionBadgeNumber(discussionEl, updatedBadgeNumber); imageDiffHelper.updateDiscussionBadgeNumber(discussionEl, updatedBadgeNumber);
imageDiffHelper.updateDiscussionAvatarBadgeNumber(discussionEl, updatedBadgeNumber); imageDiffHelper.updateDiscussionAvatarBadgeNumber(discussionEl, updatedBadgeNumber);
......
...@@ -66,7 +66,7 @@ describe('badge helper', () => { ...@@ -66,7 +66,7 @@ describe('badge helper', () => {
}); });
it('should set the badge text', () => { it('should set the badge text', () => {
expect(buttonEl.innerText).toEqual(badgeText); expect(buttonEl.textContent).toEqual(badgeText);
}); });
it('should set the button coordinates', () => { it('should set the button coordinates', () => {
...@@ -120,7 +120,7 @@ describe('badge helper', () => { ...@@ -120,7 +120,7 @@ describe('badge helper', () => {
}); });
it('should update badge number', () => { it('should update badge number', () => {
expect(avatarBadgeEl.innerText).toEqual(badgeNumber.toString()); expect(avatarBadgeEl.textContent).toEqual(badgeNumber.toString());
}); });
it('should remove hidden class', () => { it('should remove hidden class', () => {
......
...@@ -128,8 +128,8 @@ describe('commentIndicatorHelper', () => { ...@@ -128,8 +128,8 @@ describe('commentIndicatorHelper', () => {
currentTarget: containerEl.querySelector('button'), currentTarget: containerEl.querySelector('button'),
}; };
spyOn(event, 'stopPropagation'); jest.spyOn(event, 'stopPropagation').mockImplementation(() => {});
spyOn(textAreaEl, 'focus'); jest.spyOn(textAreaEl, 'focus').mockImplementation(() => {});
commentIndicatorHelper.commentIndicatorOnClick(event); commentIndicatorHelper.commentIndicatorOnClick(event);
}); });
......
...@@ -44,7 +44,7 @@ describe('domHelper', () => { ...@@ -44,7 +44,7 @@ describe('domHelper', () => {
}); });
it('should update avatar badge number', () => { it('should update avatar badge number', () => {
expect(discussionEl.querySelector('.badge').innerText).toEqual(badgeNumber.toString()); expect(discussionEl.querySelector('.badge').textContent).toEqual(badgeNumber.toString());
}); });
}); });
...@@ -60,7 +60,7 @@ describe('domHelper', () => { ...@@ -60,7 +60,7 @@ describe('domHelper', () => {
}); });
it('should update discussion badge number', () => { it('should update discussion badge number', () => {
expect(discussionEl.querySelector('.badge').innerText).toEqual(badgeNumber.toString()); expect(discussionEl.querySelector('.badge').textContent).toEqual(badgeNumber.toString());
}); });
}); });
......
...@@ -71,7 +71,7 @@ describe('ImageBadge', () => { ...@@ -71,7 +71,7 @@ describe('ImageBadge', () => {
describe('imageEl property is provided and not browser property', () => { describe('imageEl property is provided and not browser property', () => {
beforeEach(() => { beforeEach(() => {
spyOn(imageDiffHelper, 'resizeCoordinatesToImageElement').and.returnValue(true); jest.spyOn(imageDiffHelper, 'resizeCoordinatesToImageElement').mockReturnValue(true);
}); });
it('should generate browser property', () => { it('should generate browser property', () => {
......
...@@ -75,7 +75,7 @@ describe('ImageDiff', () => { ...@@ -75,7 +75,7 @@ describe('ImageDiff', () => {
describe('init', () => { describe('init', () => {
beforeEach(() => { beforeEach(() => {
spyOn(ImageDiff.prototype, 'bindEvents').and.callFake(() => {}); jest.spyOn(ImageDiff.prototype, 'bindEvents').mockImplementation(() => {});
imageDiff = new ImageDiff(element); imageDiff = new ImageDiff(element);
imageDiff.init(); imageDiff.init();
}); });
...@@ -97,19 +97,19 @@ describe('ImageDiff', () => { ...@@ -97,19 +97,19 @@ describe('ImageDiff', () => {
let imageEl; let imageEl;
beforeEach(() => { beforeEach(() => {
spyOn(imageDiffHelper, 'toggleCollapsed').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'toggleCollapsed').mockImplementation(() => {});
spyOn(imageDiffHelper, 'commentIndicatorOnClick').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'commentIndicatorOnClick').mockImplementation(() => {});
spyOn(imageDiffHelper, 'removeCommentIndicator').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'removeCommentIndicator').mockImplementation(() => {});
spyOn(ImageDiff.prototype, 'imageClicked').and.callFake(() => {}); jest.spyOn(ImageDiff.prototype, 'imageClicked').mockImplementation(() => {});
spyOn(ImageDiff.prototype, 'addBadge').and.callFake(() => {}); jest.spyOn(ImageDiff.prototype, 'addBadge').mockImplementation(() => {});
spyOn(ImageDiff.prototype, 'removeBadge').and.callFake(() => {}); jest.spyOn(ImageDiff.prototype, 'removeBadge').mockImplementation(() => {});
spyOn(ImageDiff.prototype, 'renderBadges').and.callFake(() => {}); jest.spyOn(ImageDiff.prototype, 'renderBadges').mockImplementation(() => {});
imageEl = element.querySelector('.diff-file .js-image-frame img'); imageEl = element.querySelector('.diff-file .js-image-frame img');
}); });
describe('default', () => { describe('default', () => {
beforeEach(() => { beforeEach(() => {
spyOn(imageUtility, 'isImageLoaded').and.returnValue(false); jest.spyOn(imageUtility, 'isImageLoaded').mockReturnValue(false);
imageDiff = new ImageDiff(element); imageDiff = new ImageDiff(element);
imageDiff.imageEl = imageEl; imageDiff.imageEl = imageEl;
imageDiff.bindEvents(); imageDiff.bindEvents();
...@@ -130,7 +130,7 @@ describe('ImageDiff', () => { ...@@ -130,7 +130,7 @@ describe('ImageDiff', () => {
describe('image not loaded', () => { describe('image not loaded', () => {
beforeEach(() => { beforeEach(() => {
spyOn(imageUtility, 'isImageLoaded').and.returnValue(false); jest.spyOn(imageUtility, 'isImageLoaded').mockReturnValue(false);
imageDiff = new ImageDiff(element); imageDiff = new ImageDiff(element);
imageDiff.imageEl = imageEl; imageDiff.imageEl = imageEl;
imageDiff.bindEvents(); imageDiff.bindEvents();
...@@ -146,7 +146,7 @@ describe('ImageDiff', () => { ...@@ -146,7 +146,7 @@ describe('ImageDiff', () => {
describe('canCreateNote', () => { describe('canCreateNote', () => {
beforeEach(() => { beforeEach(() => {
spyOn(imageUtility, 'isImageLoaded').and.returnValue(false); jest.spyOn(imageUtility, 'isImageLoaded').mockReturnValue(false);
imageDiff = new ImageDiff(element, { imageDiff = new ImageDiff(element, {
canCreateNote: true, canCreateNote: true,
}); });
...@@ -185,7 +185,7 @@ describe('ImageDiff', () => { ...@@ -185,7 +185,7 @@ describe('ImageDiff', () => {
describe('canCreateNote is false', () => { describe('canCreateNote is false', () => {
beforeEach(() => { beforeEach(() => {
spyOn(imageUtility, 'isImageLoaded').and.returnValue(false); jest.spyOn(imageUtility, 'isImageLoaded').mockReturnValue(false);
imageDiff = new ImageDiff(element); imageDiff = new ImageDiff(element);
imageDiff.imageEl = imageEl; imageDiff.imageEl = imageEl;
imageDiff.bindEvents(); imageDiff.bindEvents();
...@@ -202,12 +202,12 @@ describe('ImageDiff', () => { ...@@ -202,12 +202,12 @@ describe('ImageDiff', () => {
describe('imageClicked', () => { describe('imageClicked', () => {
beforeEach(() => { beforeEach(() => {
spyOn(imageDiffHelper, 'getTargetSelection').and.returnValue({ jest.spyOn(imageDiffHelper, 'getTargetSelection').mockReturnValue({
actual: {}, actual: {},
browser: {}, browser: {},
}); });
spyOn(imageDiffHelper, 'setPositionDataAttribute').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'setPositionDataAttribute').mockImplementation(() => {});
spyOn(imageDiffHelper, 'showCommentIndicator').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'showCommentIndicator').mockImplementation(() => {});
imageDiff = new ImageDiff(element); imageDiff = new ImageDiff(element);
imageDiff.imageClicked({ imageDiff.imageClicked({
detail: { detail: {
...@@ -231,7 +231,7 @@ describe('ImageDiff', () => { ...@@ -231,7 +231,7 @@ describe('ImageDiff', () => {
describe('renderBadges', () => { describe('renderBadges', () => {
beforeEach(() => { beforeEach(() => {
spyOn(ImageDiff.prototype, 'renderBadge').and.callFake(() => {}); jest.spyOn(ImageDiff.prototype, 'renderBadge').mockImplementation(() => {});
imageDiff = new ImageDiff(element); imageDiff = new ImageDiff(element);
imageDiff.renderBadges(); imageDiff.renderBadges();
}); });
...@@ -239,7 +239,7 @@ describe('ImageDiff', () => { ...@@ -239,7 +239,7 @@ describe('ImageDiff', () => {
it('should call renderBadge for each discussionEl', () => { it('should call renderBadge for each discussionEl', () => {
const discussionEls = element.querySelectorAll('.note-container .discussion-notes .notes'); const discussionEls = element.querySelectorAll('.note-container .discussion-notes .notes');
expect(imageDiff.renderBadge.calls.count()).toEqual(discussionEls.length); expect(imageDiff.renderBadge.mock.calls.length).toEqual(discussionEls.length);
}); });
}); });
...@@ -247,9 +247,9 @@ describe('ImageDiff', () => { ...@@ -247,9 +247,9 @@ describe('ImageDiff', () => {
let discussionEls; let discussionEls;
beforeEach(() => { beforeEach(() => {
spyOn(imageDiffHelper, 'addImageBadge').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'addImageBadge').mockImplementation(() => {});
spyOn(imageDiffHelper, 'addImageCommentBadge').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'addImageCommentBadge').mockImplementation(() => {});
spyOn(imageDiffHelper, 'generateBadgeFromDiscussionDOM').and.returnValue({ jest.spyOn(imageDiffHelper, 'generateBadgeFromDiscussionDOM').mockReturnValue({
browser: {}, browser: {},
noteId: 'noteId', noteId: 'noteId',
}); });
...@@ -282,9 +282,9 @@ describe('ImageDiff', () => { ...@@ -282,9 +282,9 @@ describe('ImageDiff', () => {
describe('addBadge', () => { describe('addBadge', () => {
beforeEach(() => { beforeEach(() => {
spyOn(imageDiffHelper, 'addImageBadge').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'addImageBadge').mockImplementation(() => {});
spyOn(imageDiffHelper, 'addAvatarBadge').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'addAvatarBadge').mockImplementation(() => {});
spyOn(imageDiffHelper, 'updateDiscussionBadgeNumber').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'updateDiscussionBadgeNumber').mockImplementation(() => {});
imageDiff = new ImageDiff(element); imageDiff = new ImageDiff(element);
imageDiff.imageFrameEl = element.querySelector('.diff-file .js-image-frame'); imageDiff.imageFrameEl = element.querySelector('.diff-file .js-image-frame');
imageDiff.addBadge({ imageDiff.addBadge({
...@@ -320,8 +320,8 @@ describe('ImageDiff', () => { ...@@ -320,8 +320,8 @@ describe('ImageDiff', () => {
beforeEach(() => { beforeEach(() => {
const { imageMeta } = mockData; const { imageMeta } = mockData;
spyOn(imageDiffHelper, 'updateDiscussionBadgeNumber').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'updateDiscussionBadgeNumber').mockImplementation(() => {});
spyOn(imageDiffHelper, 'updateDiscussionAvatarBadgeNumber').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'updateDiscussionAvatarBadgeNumber').mockImplementation(() => {});
imageDiff = new ImageDiff(element); imageDiff = new ImageDiff(element);
imageDiff.imageBadges = [imageMeta, imageMeta, imageMeta]; imageDiff.imageBadges = [imageMeta, imageMeta, imageMeta];
imageDiff.imageFrameEl = element.querySelector('.diff-file .js-image-frame'); imageDiff.imageFrameEl = element.querySelector('.diff-file .js-image-frame');
...@@ -336,8 +336,8 @@ describe('ImageDiff', () => { ...@@ -336,8 +336,8 @@ describe('ImageDiff', () => {
it('should update next imageBadgeEl value', () => { it('should update next imageBadgeEl value', () => {
const imageBadgeEls = imageDiff.imageFrameEl.querySelectorAll('.badge'); const imageBadgeEls = imageDiff.imageFrameEl.querySelectorAll('.badge');
expect(imageBadgeEls[0].innerText).toEqual('1'); expect(imageBadgeEls[0].textContent).toEqual('1');
expect(imageBadgeEls[1].innerText).toEqual('2'); expect(imageBadgeEls[1].textContent).toEqual('2');
expect(imageBadgeEls.length).toEqual(2); expect(imageBadgeEls.length).toEqual(2);
}); });
......
...@@ -76,8 +76,8 @@ describe('ReplacedImageDiff', () => { ...@@ -76,8 +76,8 @@ describe('ReplacedImageDiff', () => {
describe('init', () => { describe('init', () => {
beforeEach(() => { beforeEach(() => {
spyOn(ReplacedImageDiff.prototype, 'bindEvents').and.callFake(() => {}); jest.spyOn(ReplacedImageDiff.prototype, 'bindEvents').mockImplementation(() => {});
spyOn(ReplacedImageDiff.prototype, 'generateImageEls').and.callFake(() => {}); jest.spyOn(ReplacedImageDiff.prototype, 'generateImageEls').mockImplementation(() => {});
replacedImageDiff = new ReplacedImageDiff(element); replacedImageDiff = new ReplacedImageDiff(element);
replacedImageDiff.init(); replacedImageDiff.init();
...@@ -140,7 +140,7 @@ describe('ReplacedImageDiff', () => { ...@@ -140,7 +140,7 @@ describe('ReplacedImageDiff', () => {
describe('generateImageEls', () => { describe('generateImageEls', () => {
beforeEach(() => { beforeEach(() => {
spyOn(ReplacedImageDiff.prototype, 'bindEvents').and.callFake(() => {}); jest.spyOn(ReplacedImageDiff.prototype, 'bindEvents').mockImplementation(() => {});
replacedImageDiff = new ReplacedImageDiff(element, { replacedImageDiff = new ReplacedImageDiff(element, {
canCreateNote: false, canCreateNote: false,
...@@ -163,7 +163,7 @@ describe('ReplacedImageDiff', () => { ...@@ -163,7 +163,7 @@ describe('ReplacedImageDiff', () => {
describe('bindEvents', () => { describe('bindEvents', () => {
beforeEach(() => { beforeEach(() => {
spyOn(ImageDiff.prototype, 'bindEvents').and.callFake(() => {}); jest.spyOn(ImageDiff.prototype, 'bindEvents').mockImplementation(() => {});
replacedImageDiff = new ReplacedImageDiff(element); replacedImageDiff = new ReplacedImageDiff(element);
setupViewModesEls(); setupViewModesEls();
...@@ -176,7 +176,7 @@ describe('ReplacedImageDiff', () => { ...@@ -176,7 +176,7 @@ describe('ReplacedImageDiff', () => {
}); });
it('should register click eventlistener to 2-up view mode', done => { it('should register click eventlistener to 2-up view mode', done => {
spyOn(ReplacedImageDiff.prototype, 'changeView').and.callFake(viewMode => { jest.spyOn(ReplacedImageDiff.prototype, 'changeView').mockImplementation(viewMode => {
expect(viewMode).toEqual(viewTypes.TWO_UP); expect(viewMode).toEqual(viewTypes.TWO_UP);
done(); done();
}); });
...@@ -186,7 +186,7 @@ describe('ReplacedImageDiff', () => { ...@@ -186,7 +186,7 @@ describe('ReplacedImageDiff', () => {
}); });
it('should register click eventlistener to swipe view mode', done => { it('should register click eventlistener to swipe view mode', done => {
spyOn(ReplacedImageDiff.prototype, 'changeView').and.callFake(viewMode => { jest.spyOn(ReplacedImageDiff.prototype, 'changeView').mockImplementation(viewMode => {
expect(viewMode).toEqual(viewTypes.SWIPE); expect(viewMode).toEqual(viewTypes.SWIPE);
done(); done();
}); });
...@@ -196,7 +196,7 @@ describe('ReplacedImageDiff', () => { ...@@ -196,7 +196,7 @@ describe('ReplacedImageDiff', () => {
}); });
it('should register click eventlistener to onion skin view mode', done => { it('should register click eventlistener to onion skin view mode', done => {
spyOn(ReplacedImageDiff.prototype, 'changeView').and.callFake(viewMode => { jest.spyOn(ReplacedImageDiff.prototype, 'changeView').mockImplementation(viewMode => {
expect(viewMode).toEqual(viewTypes.SWIPE); expect(viewMode).toEqual(viewTypes.SWIPE);
done(); done();
}); });
...@@ -247,7 +247,7 @@ describe('ReplacedImageDiff', () => { ...@@ -247,7 +247,7 @@ describe('ReplacedImageDiff', () => {
describe('changeView', () => { describe('changeView', () => {
beforeEach(() => { beforeEach(() => {
replacedImageDiff = new ReplacedImageDiff(element); replacedImageDiff = new ReplacedImageDiff(element);
spyOn(imageDiffHelper, 'removeCommentIndicator').and.returnValue({ jest.spyOn(imageDiffHelper, 'removeCommentIndicator').mockReturnValue({
removed: false, removed: false,
}); });
setupImageFrameEls(); setupImageFrameEls();
...@@ -265,13 +265,12 @@ describe('ReplacedImageDiff', () => { ...@@ -265,13 +265,12 @@ describe('ReplacedImageDiff', () => {
describe('valid viewType', () => { describe('valid viewType', () => {
beforeEach(() => { beforeEach(() => {
jasmine.clock().install(); jest.spyOn(ReplacedImageDiff.prototype, 'renderNewView').mockImplementation(() => {});
spyOn(ReplacedImageDiff.prototype, 'renderNewView').and.callFake(() => {});
replacedImageDiff.changeView(viewTypes.ONION_SKIN); replacedImageDiff.changeView(viewTypes.ONION_SKIN);
}); });
afterEach(() => { afterEach(() => {
jasmine.clock().uninstall(); jest.clearAllTimers();
}); });
it('should call removeCommentIndicator', () => { it('should call removeCommentIndicator', () => {
...@@ -287,7 +286,7 @@ describe('ReplacedImageDiff', () => { ...@@ -287,7 +286,7 @@ describe('ReplacedImageDiff', () => {
}); });
it('should call renderNewView', () => { it('should call renderNewView', () => {
jasmine.clock().tick(251); jest.advanceTimersByTime(251);
expect(replacedImageDiff.renderNewView).toHaveBeenCalled(); expect(replacedImageDiff.renderNewView).toHaveBeenCalled();
}); });
...@@ -300,7 +299,7 @@ describe('ReplacedImageDiff', () => { ...@@ -300,7 +299,7 @@ describe('ReplacedImageDiff', () => {
}); });
it('should call renderBadges', () => { it('should call renderBadges', () => {
spyOn(ReplacedImageDiff.prototype, 'renderBadges').and.callFake(() => {}); jest.spyOn(ReplacedImageDiff.prototype, 'renderBadges').mockImplementation(() => {});
replacedImageDiff.renderNewView({ replacedImageDiff.renderNewView({
removed: false, removed: false,
...@@ -326,14 +325,16 @@ describe('ReplacedImageDiff', () => { ...@@ -326,14 +325,16 @@ describe('ReplacedImageDiff', () => {
}); });
it('should pass showCommentIndicator normalized indicator values', done => { it('should pass showCommentIndicator normalized indicator values', done => {
spyOn(imageDiffHelper, 'showCommentIndicator').and.callFake(() => {}); jest.spyOn(imageDiffHelper, 'showCommentIndicator').mockImplementation(() => {});
spyOn(imageDiffHelper, 'resizeCoordinatesToImageElement').and.callFake((imageEl, meta) => { jest
expect(meta.x).toEqual(indicator.x); .spyOn(imageDiffHelper, 'resizeCoordinatesToImageElement')
expect(meta.y).toEqual(indicator.y); .mockImplementation((imageEl, meta) => {
expect(meta.width).toEqual(indicator.image.width); expect(meta.x).toEqual(indicator.x);
expect(meta.height).toEqual(indicator.image.height); expect(meta.y).toEqual(indicator.y);
done(); expect(meta.width).toEqual(indicator.image.width);
}); expect(meta.height).toEqual(indicator.image.height);
done();
});
replacedImageDiff.renderNewView(indicator); replacedImageDiff.renderNewView(indicator);
}); });
...@@ -341,13 +342,13 @@ describe('ReplacedImageDiff', () => { ...@@ -341,13 +342,13 @@ describe('ReplacedImageDiff', () => {
const normalized = { const normalized = {
normalized: true, normalized: true,
}; };
spyOn(imageDiffHelper, 'resizeCoordinatesToImageElement').and.returnValue(normalized); jest.spyOn(imageDiffHelper, 'resizeCoordinatesToImageElement').mockReturnValue(normalized);
spyOn(imageDiffHelper, 'showCommentIndicator').and.callFake( jest
(imageFrameEl, normalizedIndicator) => { .spyOn(imageDiffHelper, 'showCommentIndicator')
.mockImplementation((imageFrameEl, normalizedIndicator) => {
expect(normalizedIndicator).toEqual(normalized); expect(normalizedIndicator).toEqual(normalized);
done(); done();
}, });
);
replacedImageDiff.renderNewView(indicator); replacedImageDiff.renderNewView(indicator);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment