2022-07-16 23:28:13 +05:30
|
|
|
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
|
2019-12-04 20:38:33 +05:30
|
|
|
import initImageDiffHelper from '~/image_diff/helpers/init_image_diff';
|
2021-03-11 19:13:27 +05:30
|
|
|
import initDiscussionTab from '~/image_diff/init_discussion_tab';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
describe('initDiscussionTab', () => {
|
|
|
|
beforeEach(() => {
|
2022-07-16 23:28:13 +05:30
|
|
|
setHTMLFixture(`
|
2018-03-17 18:26:18 +05:30
|
|
|
<div class="timeline-content">
|
|
|
|
<div class="diff-file js-image-file"></div>
|
|
|
|
<div class="diff-file js-image-file"></div>
|
|
|
|
</div>
|
|
|
|
`);
|
|
|
|
});
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
afterEach(() => {
|
|
|
|
resetHTMLFixture();
|
|
|
|
});
|
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
it('should pass canCreateNote as false to initImageDiff', () => {
|
2020-03-13 15:44:24 +05:30
|
|
|
jest
|
|
|
|
.spyOn(initImageDiffHelper, 'initImageDiff')
|
|
|
|
.mockImplementation((diffFileEl, canCreateNote) => {
|
|
|
|
expect(canCreateNote).toEqual(false);
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
initDiscussionTab();
|
|
|
|
});
|
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
it('should pass renderCommentBadge as true to initImageDiff', () => {
|
2020-03-13 15:44:24 +05:30
|
|
|
jest
|
|
|
|
.spyOn(initImageDiffHelper, 'initImageDiff')
|
|
|
|
.mockImplementation((diffFileEl, canCreateNote, renderCommentBadge) => {
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(renderCommentBadge).toEqual(true);
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
initDiscussionTab();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should call initImageDiff for each diffFileEls', () => {
|
2020-03-13 15:44:24 +05:30
|
|
|
jest.spyOn(initImageDiffHelper, 'initImageDiff').mockImplementation(() => {});
|
2018-03-17 18:26:18 +05:30
|
|
|
initDiscussionTab();
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(initImageDiffHelper.initImageDiff.mock.calls.length).toEqual(2);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|