gitlab-org--gitlab-foss/spec/frontend/image_diff/init_discussion_tab_spec.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

import initImageDiffHelper from '~/image_diff/helpers/init_image_diff';
import initDiscussionTab from '~/image_diff/init_discussion_tab';
2017-10-07 04:25:17 +00:00
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>
`);
});
it('should pass canCreateNote as false to initImageDiff', (done) => {
jest
.spyOn(initImageDiffHelper, 'initImageDiff')
.mockImplementation((diffFileEl, canCreateNote) => {
expect(canCreateNote).toEqual(false);
done();
});
2017-10-07 04:25:17 +00:00
initDiscussionTab();
});
it('should pass renderCommentBadge as true to initImageDiff', (done) => {
jest
.spyOn(initImageDiffHelper, 'initImageDiff')
.mockImplementation((diffFileEl, canCreateNote, renderCommentBadge) => {
2018-10-17 07:13:26 +00:00
expect(renderCommentBadge).toEqual(true);
done();
});
2017-10-07 04:25:17 +00:00
initDiscussionTab();
});
it('should call initImageDiff for each diffFileEls', () => {
jest.spyOn(initImageDiffHelper, 'initImageDiff').mockImplementation(() => {});
2017-10-07 04:25:17 +00:00
initDiscussionTab();
2018-10-09 18:03:09 +00:00
expect(initImageDiffHelper.initImageDiff.mock.calls.length).toEqual(2);
2017-10-07 04:25:17 +00:00
});
});