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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
a424e814
Commit
a424e814
authored
Sep 02, 2018
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for Karma Tests
parent
b8b2cb36
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
36 deletions
+33
-36
app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
...javascripts/diffs/components/diff_line_gutter_content.vue
+0
-5
spec/javascripts/diffs/components/diff_line_gutter_content_spec.js
...scripts/diffs/components/diff_line_gutter_content_spec.js
+13
-25
spec/javascripts/diffs/mock_data/diff_file.js
spec/javascripts/diffs/mock_data/diff_file.js
+1
-0
spec/javascripts/diffs/store/utils_spec.js
spec/javascripts/diffs/store/utils_spec.js
+19
-6
No files found.
app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
View file @
a424e814
...
...
@@ -65,11 +65,6 @@ export default {
required
:
false
,
default
:
false
,
},
discussions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
},
computed
:
{
...
mapState
({
...
...
spec/javascripts/diffs/components/diff_line_gutter_content_spec.js
View file @
a424e814
...
...
@@ -6,13 +6,12 @@ import discussionsMockData from '../mock_data/diff_discussions';
import
diffFileMockData
from
'
../mock_data/diff_file
'
;
describe
(
'
DiffLineGutterContent
'
,
()
=>
{
const
getDiscussionsMockData
=
()
=>
[
Object
.
assign
({},
discussionsMockData
)];
const
getDiffFileMock
=
()
=>
Object
.
assign
({},
diffFileMockData
);
const
createComponent
=
(
options
=
{})
=>
{
const
cmp
=
Vue
.
extend
(
DiffLineGutterContent
);
const
props
=
Object
.
assign
({},
options
);
props
.
line
=
{
lineC
ode
:
'
LC_42
'
,
c
ode
:
'
LC_42
'
,
type
:
'
new
'
,
oldLine
:
null
,
newLine
:
1
,
...
...
@@ -26,51 +25,42 @@ describe('DiffLineGutterContent', () => {
return
createComponentWithStore
(
cmp
,
store
,
props
).
$mount
();
};
const
setDiscussions
=
component
=>
{
component
.
$store
.
dispatch
(
'
setInitialNotes
'
,
getDiscussionsMockData
());
};
const
resetDiscussions
=
component
=>
{
component
.
$store
.
dispatch
(
'
setInitialNotes
'
,
[]);
};
describe
(
'
computed
'
,
()
=>
{
describe
(
'
lineHref
'
,
()
=>
{
it
(
'
should prepend # to lineCode
'
,
()
=>
{
const
lineCode
=
'
LC_42
'
;
const
component
=
createComponent
(
{
lineCode
}
);
const
component
=
createComponent
();
expect
(
component
.
lineHref
).
toEqual
(
`#
${
lineCode
}
`
);
});
it
(
'
should return # if there is no lineCode
'
,
()
=>
{
const
component
=
createComponent
({
lineCode
:
null
});
const
component
=
createComponent
();
component
.
line
.
code
=
''
;
expect
(
component
.
lineHref
).
toEqual
(
'
#
'
);
});
});
describe
(
'
discussions, hasDiscussions, shouldShowAvatarsOnGutter
'
,
()
=>
{
it
(
'
should return empty array when there is no discussion
'
,
()
=>
{
const
component
=
createComponent
({
lineCode
:
'
LC_42
'
});
expect
(
component
.
discussions
).
toEqual
([]);
const
component
=
createComponent
();
expect
(
component
.
hasDiscussions
).
toEqual
(
false
);
expect
(
component
.
shouldShowAvatarsOnGutter
).
toEqual
(
false
);
});
it
(
'
should return discussions for the given lineCode
'
,
()
=>
{
const
{
lineCode
}
=
getDiffFileMock
().
highlightedDiffLines
[
1
];
const
component
=
createComponent
({
lineCode
,
const
cmp
=
Vue
.
extend
(
DiffLineGutterContent
);
const
props
=
{
line
:
getDiffFileMock
().
highlightedDiffLines
[
1
],
fileHash
:
getDiffFileMock
().
fileHash
,
showCommentButton
:
true
,
discussions
:
getDiscussionsMockData
(),
});
contextLinesPath
:
'
/context/lines/path
'
,
};
props
.
line
.
discussions
=
[
Object
.
assign
({},
discussionsMockData
)];
const
component
=
createComponentWithStore
(
cmp
,
store
,
props
).
$mount
();
setDiscussions
(
component
);
expect
(
component
.
discussions
).
toEqual
(
getDiscussionsMockData
());
expect
(
component
.
hasDiscussions
).
toEqual
(
true
);
expect
(
component
.
shouldShowAvatarsOnGutter
).
toEqual
(
true
);
resetDiscussions
(
component
);
});
});
});
...
...
@@ -114,9 +104,7 @@ describe('DiffLineGutterContent', () => {
lineCode
:
getDiffFileMock
().
highlightedDiffLines
[
1
].
lineCode
,
});
setDiscussions
(
component
);
expect
(
component
.
$el
.
querySelector
(
'
.diff-comment-avatar-holders
'
)).
toBeDefined
();
resetDiscussions
(
component
);
});
});
});
spec/javascripts/diffs/mock_data/diff_file.js
View file @
a424e814
...
...
@@ -99,6 +99,7 @@ export default {
type
:
'
match
'
,
oldLine
:
null
,
newLine
:
null
,
discussions
:
[],
text
:
''
,
richText
:
''
,
metaData
:
{
...
...
spec/javascripts/diffs/store/utils_spec.js
View file @
a424e814
...
...
@@ -179,32 +179,45 @@ describe('DiffsStoreUtils', () => {
describe
(
'
trimFirstCharOfLineContent
'
,
()
=>
{
it
(
'
trims the line when it starts with a space
'
,
()
=>
{
expect
(
utils
.
trimFirstCharOfLineContent
({
richText
:
'
diff
'
})).
toEqual
({
richText
:
'
diff
'
});
expect
(
utils
.
trimFirstCharOfLineContent
({
richText
:
'
diff
'
})).
toEqual
({
discussions
:
[],
richText
:
'
diff
'
,
});
});
it
(
'
trims the line when it starts with a +
'
,
()
=>
{
expect
(
utils
.
trimFirstCharOfLineContent
({
richText
:
'
+diff
'
})).
toEqual
({
richText
:
'
diff
'
});
expect
(
utils
.
trimFirstCharOfLineContent
({
richText
:
'
+diff
'
})).
toEqual
({
discussions
:
[],
richText
:
'
diff
'
,
});
});
it
(
'
trims the line when it starts with a -
'
,
()
=>
{
expect
(
utils
.
trimFirstCharOfLineContent
({
richText
:
'
-diff
'
})).
toEqual
({
richText
:
'
diff
'
});
expect
(
utils
.
trimFirstCharOfLineContent
({
richText
:
'
-diff
'
})).
toEqual
({
discussions
:
[],
richText
:
'
diff
'
,
});
});
it
(
'
does not trims the line when it starts with a letter
'
,
()
=>
{
expect
(
utils
.
trimFirstCharOfLineContent
({
richText
:
'
diff
'
})).
toEqual
({
richText
:
'
diff
'
});
expect
(
utils
.
trimFirstCharOfLineContent
({
richText
:
'
diff
'
})).
toEqual
({
discussions
:
[],
richText
:
'
diff
'
,
});
});
it
(
'
does not modify the provided object
'
,
()
=>
{
const
lineObj
=
{
discussions
:
[],
richText
:
'
diff
'
,
};
utils
.
trimFirstCharOfLineContent
(
lineObj
);
expect
(
lineObj
).
toEqual
({
richText
:
'
diff
'
});
expect
(
lineObj
).
toEqual
({
discussions
:
[],
richText
:
'
diff
'
});
});
it
(
'
handles a undefined or null parameter
'
,
()
=>
{
expect
(
utils
.
trimFirstCharOfLineContent
()).
toEqual
({});
expect
(
utils
.
trimFirstCharOfLineContent
()).
toEqual
({
discussions
:
[]
});
});
});
});
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