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:
Diffstat (limited to 'spec/frontend/diffs/components/diff_row_utils_spec.js')
-rw-r--r--spec/frontend/diffs/components/diff_row_utils_spec.js39
1 files changed, 36 insertions, 3 deletions
diff --git a/spec/frontend/diffs/components/diff_row_utils_spec.js b/spec/frontend/diffs/components/diff_row_utils_spec.js
index 6e9eb433924..bd9592e4f5e 100644
--- a/spec/frontend/diffs/components/diff_row_utils_spec.js
+++ b/spec/frontend/diffs/components/diff_row_utils_spec.js
@@ -6,6 +6,7 @@ import {
NEW_NO_NEW_LINE_TYPE,
EMPTY_CELL_TYPE,
} from '~/diffs/constants';
+import { getDiffFileMock } from 'jest/diffs/mock_data/diff_file';
const LINE_CODE = 'abc123';
@@ -108,15 +109,47 @@ describe('diff_row_utils', () => {
describe('lineHref', () => {
it(`should return #${LINE_CODE}`, () => {
- expect(utils.lineHref({ line_code: LINE_CODE })).toEqual(`#${LINE_CODE}`);
+ expect(utils.lineHref({ line_code: LINE_CODE }, {})).toEqual(`#${LINE_CODE}`);
});
it(`should return '#' if line is undefined`, () => {
- expect(utils.lineHref()).toEqual('#');
+ expect(utils.lineHref()).toEqual('');
});
it(`should return '#' if line_code is undefined`, () => {
- expect(utils.lineHref({})).toEqual('#');
+ expect(utils.lineHref({}, {})).toEqual('');
+ });
+
+ describe('pinned file', () => {
+ beforeEach(() => {
+ window.gon.features = { pinnedFile: true };
+ });
+
+ afterEach(() => {
+ delete window.gon.features;
+ });
+
+ it(`should return pinned file URL`, () => {
+ const diffFile = getDiffFileMock();
+ expect(utils.lineHref({ line_code: LINE_CODE }, { diffFile })).toEqual(
+ `?pin=${diffFile.file_hash}#${LINE_CODE}`,
+ );
+ });
+ });
+ });
+
+ describe('pinnedFileHref', () => {
+ beforeEach(() => {
+ window.gon.features = { pinnedFile: true };
+ });
+
+ afterEach(() => {
+ delete window.gon.features;
+ });
+
+ it(`should return pinned file URL`, () => {
+ const diffFile = getDiffFileMock();
+ expect(utils.pinnedFileHref(diffFile)).toEqual(`?pin=${diffFile.file_hash}`);
});
});