Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
15feba24
Commit
15feba24
authored
Dec 11, 2020
by
Thomas Randolph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test IDs being added to diff files
parent
88e63ada
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
43 deletions
+66
-43
spec/frontend/diffs/utils/diff_file_spec.js
spec/frontend/diffs/utils/diff_file_spec.js
+66
-43
No files found.
spec/frontend/diffs/utils/diff_file_spec.js
View file @
15feba24
import
{
prepareRawDiffFile
}
from
'
~/diffs/utils/diff_file
'
;
const
DIFF_FILES
=
[
function
getDiffFiles
()
{
return
[
{
blob
:
{
id
:
'
abc
'
,
mode
:
'
100644
'
,
},
file_hash
:
'
ABC
'
,
// This file is just a normal file
file_identifier_hash
:
'
ABC1
'
,
content_sha
:
'
C047347
'
,
},
{
blob
:
{
id
:
'
bcd
'
,
mode
:
'
100644
'
,
},
file_hash
:
'
DEF
'
,
// This file replaces a symlink
file_identifier_hash
:
'
DEF1
'
,
content_sha
:
'
C047347
'
,
a_mode
:
'
0
'
,
b_mode
:
'
0755
'
,
},
{
blob
:
{
id
:
'
cde
'
,
mode
:
'
100644
'
,
},
file_hash
:
'
DEF
'
,
// This symlink is replaced by a file
file_identifier_hash
:
'
DEF2
'
,
content_sha
:
'
C047347
'
,
a_mode
:
'
120000
'
,
b_mode
:
'
0
'
,
},
{
blob
:
{
id
:
'
def
'
,
mode
:
'
100644
'
,
},
file_hash
:
'
GHI
'
,
// This symlink replaces a file
file_identifier_hash
:
'
GHI1
'
,
content_sha
:
'
C047347
'
,
a_mode
:
'
0
'
,
b_mode
:
'
120000
'
,
},
{
blob
:
{
id
:
'
efg
'
,
mode
:
'
100644
'
,
},
file_hash
:
'
GHI
'
,
// This file is replaced by a symlink
file_identifier_hash
:
'
GHI2
'
,
content_sha
:
'
C047347
'
,
a_mode
:
'
0755
'
,
b_mode
:
'
0
'
,
},
];
];
}
function
makeBrokenSymlinkObject
(
replaced
,
wasSymbolic
,
isSymbolic
,
wasReal
,
isReal
)
{
return
{
replaced
,
...
...
@@ -58,6 +49,12 @@ function makeBrokenSymlinkObject(replaced, wasSymbolic, isSymbolic, wasReal, isR
describe
(
'
diff_file utilities
'
,
()
=>
{
describe
(
'
prepareRawDiffFile
'
,
()
=>
{
let
files
;
beforeEach
(()
=>
{
files
=
getDiffFiles
();
});
it
.
each
`
fileIndex | description | brokenSymlink
${
0
}
|
${
'
a file that is not symlink-adjacent
'
}
|
${
false
}
...
...
@@ -69,12 +66,38 @@ describe('diff_file utilities', () => {
'
properly marks $description with the correct .brokenSymlink value
'
,
({
fileIndex
,
brokenSymlink
})
=>
{
const
preppedRaw
=
prepareRawDiffFile
({
file
:
DIFF_FILES
[
fileIndex
],
allFiles
:
DIFF_FILES
,
file
:
files
[
fileIndex
],
allFiles
:
files
,
});
expect
(
preppedRaw
.
brokenSymlink
).
toStrictEqual
(
brokenSymlink
);
},
);
it
.
each
`
fileIndex | id
${
0
}
|
${
'
e075da30-4ec7-4e1c-a505-fe0fb0efe2d8
'
}
${
1
}
|
${
'
5ab05419-123e-4d18-8454-0b8c3d9f3f91
'
}
${
2
}
|
${
'
94eb6bba-575c-4504-bd8e-5d302364d31e
'
}
${
3
}
|
${
'
06d669b2-29b7-4f47-9731-33fc38a8db61
'
}
${
4
}
|
${
'
edd3e8f9-07f9-4647-8171-544c72e5a175
'
}
`
(
'
sets the file id properly { id: $id } on normal diff files
'
,
({
fileIndex
,
id
})
=>
{
const
preppedFile
=
prepareRawDiffFile
({
file
:
files
[
fileIndex
],
allFiles
:
files
,
});
expect
(
preppedFile
.
id
).
toBe
(
id
);
});
it
(
'
does not set the `id` property for metadata diff files
'
,
()
=>
{
const
preppedFile
=
prepareRawDiffFile
({
file
:
files
[
0
],
allFiles
:
files
,
meta
:
true
,
});
expect
(
preppedFile
).
not
.
toHaveProp
(
'
id
'
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment