Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-10-26 18:10:10 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-10-26 18:10:10 +0300
commitc86ec1d072338034a312bb4be0ff175892fa01b7 (patch)
treee67bb3ce9beb174a20991e53d998f59adc35f02e /spec/frontend/blob
parentc15582526dd15f5ea8fac0906624cc5cd2db03ab (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/blob')
-rw-r--r--spec/frontend/blob/blob_blame_link_spec.js12
-rw-r--r--spec/frontend/blob/utils_spec.js28
2 files changed, 38 insertions, 2 deletions
diff --git a/spec/frontend/blob/blob_blame_link_spec.js b/spec/frontend/blob/blob_blame_link_spec.js
index 060e8803520..18adeed1f02 100644
--- a/spec/frontend/blob/blob_blame_link_spec.js
+++ b/spec/frontend/blob/blob_blame_link_spec.js
@@ -1,5 +1,5 @@
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
-import addBlameLink from '~/blob/blob_blame_link';
+import { addBlameLink } from '~/blob/blob_blame_link';
describe('Blob links', () => {
const mouseoverEvent = new MouseEvent('mouseover', {
@@ -10,9 +10,10 @@ describe('Blob links', () => {
beforeEach(() => {
setHTMLFixture(`
- <div id="blob-content-holder">
+ <div id="blob-content-holder" class="js-per-page" data-blame-per-page="1000">
<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>
+ <a id="L1005" href="#L1005" data-line-number="1005" class="file-line-num js-line-links">1005</a>
</div>
<pre id="LC5">Line 5 content</pre>
</div>
@@ -44,4 +45,11 @@ describe('Blob links', () => {
expect(lineLink).not.toBeNull();
expect(lineLink.getAttribute('href')).toBe('#L5');
});
+
+ it('adds page parameter when needed', () => {
+ document.querySelectorAll('.file-line-num')[1].dispatchEvent(mouseoverEvent);
+ const blameLink = document.querySelectorAll('.file-line-blame')[1];
+ expect(blameLink).not.toBeNull();
+ expect(blameLink.getAttribute('href')).toBe('/blamePath?page=2#L1005');
+ });
});
diff --git a/spec/frontend/blob/utils_spec.js b/spec/frontend/blob/utils_spec.js
index a543c0060cb..9f597aa016e 100644
--- a/spec/frontend/blob/utils_spec.js
+++ b/spec/frontend/blob/utils_spec.js
@@ -41,4 +41,32 @@ describe('Blob utilities', () => {
);
});
});
+ describe('getPageParamValue', () => {
+ it('returns empty string if no perPage parameter is provided', () => {
+ const pageParamValue = utils.getPageParamValue(5);
+ expect(pageParamValue).toEqual('');
+ });
+ it('returns empty string if page is equal 1', () => {
+ const pageParamValue = utils.getPageParamValue(1000, 1000);
+ expect(pageParamValue).toEqual('');
+ });
+ it('returns correct page parameter value', () => {
+ const pageParamValue = utils.getPageParamValue(1001, 1000);
+ expect(pageParamValue).toEqual(2);
+ });
+ it('accepts strings as a parameter and returns correct result', () => {
+ const pageParamValue = utils.getPageParamValue('1001', '1000');
+ expect(pageParamValue).toEqual(2);
+ });
+ });
+ describe('getPageSearchString', () => {
+ it('returns empty search string if page parameter is empty value', () => {
+ const path = utils.getPageSearchString('/blamePath', '');
+ expect(path).toEqual('');
+ });
+ it('returns correct search string if value is provided', () => {
+ const searchString = utils.getPageSearchString('/blamePath', 3);
+ expect(searchString).toEqual('?page=3');
+ });
+ });
});