diff options
Diffstat (limited to 'spec/frontend/image_diff/init_discussion_tab_spec.js')
-rw-r--r-- | spec/frontend/image_diff/init_discussion_tab_spec.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/frontend/image_diff/init_discussion_tab_spec.js b/spec/frontend/image_diff/init_discussion_tab_spec.js new file mode 100644 index 00000000000..f459fdf5a08 --- /dev/null +++ b/spec/frontend/image_diff/init_discussion_tab_spec.js @@ -0,0 +1,42 @@ +import initDiscussionTab from '~/image_diff/init_discussion_tab'; +import initImageDiffHelper from '~/image_diff/helpers/init_image_diff'; + +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(); + }); + + initDiscussionTab(); + }); + + it('should pass renderCommentBadge as true to initImageDiff', done => { + jest + .spyOn(initImageDiffHelper, 'initImageDiff') + .mockImplementation((diffFileEl, canCreateNote, renderCommentBadge) => { + expect(renderCommentBadge).toEqual(true); + done(); + }); + + initDiscussionTab(); + }); + + it('should call initImageDiff for each diffFileEls', () => { + jest.spyOn(initImageDiffHelper, 'initImageDiff').mockImplementation(() => {}); + initDiscussionTab(); + + expect(initImageDiffHelper.initImageDiff.mock.calls.length).toEqual(2); + }); +}); |