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(() => {
|
|
|
|
setFixtures(`
|
|
|
|
<div class="timeline-content">
|
|
|
|
<div class="diff-file js-image-file"></div>
|
|
|
|
<div class="diff-file js-image-file"></div>
|
|
|
|
</div>
|
|
|
|
`);
|
|
|
|
});
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
it('should pass canCreateNote as false to initImageDiff', (done) => {
|
2020-03-13 15:44:24 +05:30
|
|
|
jest
|
|
|
|
.spyOn(initImageDiffHelper, 'initImageDiff')
|
|
|
|
.mockImplementation((diffFileEl, canCreateNote) => {
|
|
|
|
expect(canCreateNote).toEqual(false);
|
|
|
|
done();
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
initDiscussionTab();
|
|
|
|
});
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
it('should pass renderCommentBadge as true to initImageDiff', (done) => {
|
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);
|
|
|
|
done();
|
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
|
|
|
});
|
|
|
|
});
|