2017-10-07 00:25:17 -04:00
|
|
|
import initDiscussionTab from '~/image_diff/init_discussion_tab';
|
|
|
|
import imageDiffHelper from '~/image_diff/helpers/index';
|
|
|
|
|
|
|
|
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-10-17 03:13:26 -04:00
|
|
|
it('should pass canCreateNote as false to initImageDiff', done => {
|
2017-10-07 00:25:17 -04:00
|
|
|
spyOn(imageDiffHelper, 'initImageDiff').and.callFake((diffFileEl, canCreateNote) => {
|
|
|
|
expect(canCreateNote).toEqual(false);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
initDiscussionTab();
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('should pass renderCommentBadge as true to initImageDiff', done => {
|
|
|
|
spyOn(imageDiffHelper, 'initImageDiff').and.callFake(
|
|
|
|
(diffFileEl, canCreateNote, renderCommentBadge) => {
|
|
|
|
expect(renderCommentBadge).toEqual(true);
|
|
|
|
done();
|
|
|
|
},
|
|
|
|
);
|
2017-10-07 00:25:17 -04:00
|
|
|
|
|
|
|
initDiscussionTab();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should call initImageDiff for each diffFileEls', () => {
|
|
|
|
spyOn(imageDiffHelper, 'initImageDiff').and.callFake(() => {});
|
|
|
|
initDiscussionTab();
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2017-10-07 00:25:17 -04:00
|
|
|
expect(imageDiffHelper.initImageDiff.calls.count()).toEqual(2);
|
|
|
|
});
|
|
|
|
});
|