diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-24 18:12:18 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-24 18:12:18 +0000 |
commit | 06c57a837802f789b9276e23d7f505d95270f033 (patch) | |
tree | b45a80632d84a459b11376e1b575928c911eb045 /spec/frontend/blob/blob_blame_link_spec.js | |
parent | 53ab147992c8e791582f625c80811fdda5ba4d5a (diff) | |
download | gitlab-ce-06c57a837802f789b9276e23d7f505d95270f033.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/blob/blob_blame_link_spec.js')
-rw-r--r-- | spec/frontend/blob/blob_blame_link_spec.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/frontend/blob/blob_blame_link_spec.js b/spec/frontend/blob/blob_blame_link_spec.js new file mode 100644 index 00000000000..0d19177a11f --- /dev/null +++ b/spec/frontend/blob/blob_blame_link_spec.js @@ -0,0 +1,47 @@ +import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; +import addBlameLink from '~/blob/blob_blame_link'; + +describe('Blob links', () => { + const mouseoverEvent = new MouseEvent('mouseover', { + view: window, + bubbles: true, + cancelable: true, + }); + + beforeEach(() => { + setHTMLFixture(` + <div id="blob-content-holder"> + <div class="line-numbers" data-blame-path="/blamePath"> + <a id="L5" href="#L5" data-line-number="5" class="file-line-num js-line-links">5</a> + </div> + <pre id="LC5">Line 5 content</pre> + </div> + `); + + addBlameLink('#blob-content-holder', 'js-line-links'); + document.querySelector('.file-line-num').dispatchEvent(mouseoverEvent); + }); + + afterEach(() => { + resetHTMLFixture(); + }); + + it('adds wrapper elements with correct classes', () => { + const wrapper = document.querySelector('.line-links'); + + expect(wrapper).toBeTruthy(); + expect(wrapper.classList).toContain('diff-line-num'); + }); + + it('adds blame link with correct classes and path', () => { + const blameLink = document.querySelector('.file-line-blame'); + expect(blameLink).toBeTruthy(); + expect(blameLink.getAttribute('href')).toBe('/blamePath#L5'); + }); + + it('adds line link within wraper with correct classes and path', () => { + const lineLink = document.querySelector('.file-line-num'); + expect(lineLink).toBeTruthy(); + expect(lineLink.getAttribute('href')).toBe('#L5'); + }); +}); |