2022-05-13 08:08:49 -04:00
|
|
|
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
|
2019-09-18 10:02:45 -04:00
|
|
|
import initImageDiffHelper from '~/image_diff/helpers/init_image_diff';
|
2021-02-14 13:09:20 -05:00
|
|
|
import initDiscussionTab from '~/image_diff/init_discussion_tab';
|
2017-10-07 00:25:17 -04:00
|
|
|
|
|
|
|
describe('initDiscussionTab', () => {
|
|
|
|
beforeEach(() => {
|
2022-05-13 08:08:49 -04:00
|
|
|
setHTMLFixture(`
|
2017-10-07 00:25:17 -04:00
|
|
|
<div class="timeline-content">
|
|
|
|
<div class="diff-file js-image-file"></div>
|
|
|
|
<div class="diff-file js-image-file"></div>
|
|
|
|
</div>
|
|
|
|
`);
|
|
|
|
});
|
|
|
|
|
2022-05-13 08:08:49 -04:00
|
|
|
afterEach(() => {
|
|
|
|
resetHTMLFixture();
|
|
|
|
});
|
|
|
|
|
2022-04-18 14:10:36 -04:00
|
|
|
it('should pass canCreateNote as false to initImageDiff', () => {
|
2019-12-20 10:07:34 -05:00
|
|
|
jest
|
|
|
|
.spyOn(initImageDiffHelper, 'initImageDiff')
|
|
|
|
.mockImplementation((diffFileEl, canCreateNote) => {
|
|
|
|
expect(canCreateNote).toEqual(false);
|
|
|
|
});
|
2017-10-07 00:25:17 -04:00
|
|
|
|
|
|
|
initDiscussionTab();
|
|
|
|
});
|
|
|
|
|
2022-04-18 14:10:36 -04:00
|
|
|
it('should pass renderCommentBadge as true to initImageDiff', () => {
|
2019-12-20 10:07:34 -05:00
|
|
|
jest
|
|
|
|
.spyOn(initImageDiffHelper, 'initImageDiff')
|
|
|
|
.mockImplementation((diffFileEl, canCreateNote, renderCommentBadge) => {
|
2018-10-17 03:13:26 -04:00
|
|
|
expect(renderCommentBadge).toEqual(true);
|
2019-12-20 10:07:34 -05:00
|
|
|
});
|
2017-10-07 00:25:17 -04:00
|
|
|
|
|
|
|
initDiscussionTab();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should call initImageDiff for each diffFileEls', () => {
|
2019-12-20 10:07:34 -05:00
|
|
|
jest.spyOn(initImageDiffHelper, 'initImageDiff').mockImplementation(() => {});
|
2017-10-07 00:25:17 -04:00
|
|
|
initDiscussionTab();
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2019-12-20 10:07:34 -05:00
|
|
|
expect(initImageDiffHelper.initImageDiff.mock.calls.length).toEqual(2);
|
2017-10-07 00:25:17 -04:00
|
|
|
});
|
|
|
|
});
|