debian-mirror-gitlab/spec/frontend/image_diff/init_discussion_tab_spec.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import initDiscussionTab from '~/image_diff/init_discussion_tab';
2019-12-04 20:38:33 +05:30
import initImageDiffHelper from '~/image_diff/helpers/init_image_diff';
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>
`);
});
2018-12-13 13:39:08 +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();
});
2018-12-13 13:39:08 +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
});
});