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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.3 KiB
JavaScript
Raw Normal View History

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