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
Boxiang Sun
gitlab-ce
Commits
c5a514de
Commit
c5a514de
authored
Jul 11, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds specs for toggleFileDiscussions action
parent
57c32c7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
3 deletions
+45
-3
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/actions.js
+1
-3
spec/javascripts/diffs/store/actions_spec.js
spec/javascripts/diffs/store/actions_spec.js
+44
-0
No files found.
app/assets/javascripts/diffs/store/actions.js
View file @
c5a514de
...
@@ -103,9 +103,7 @@ export const toggleFileDiscussions = ({ getters, dispatch }, diff) => {
...
@@ -103,9 +103,7 @@ export const toggleFileDiscussions = ({ getters, dispatch }, diff) => {
if
(
shouldCloseAll
)
{
if
(
shouldCloseAll
)
{
dispatch
(
'
collapseDiscussion
'
,
data
,
{
root
:
true
});
dispatch
(
'
collapseDiscussion
'
,
data
,
{
root
:
true
});
}
else
if
(
shouldExpandAll
)
{
}
else
if
(
shouldExpandAll
||
(
!
shouldCloseAll
&&
!
shouldExpandAll
&&
!
discussion
.
expanded
))
{
dispatch
(
'
expandDiscussion
'
,
data
,
{
root
:
true
});
}
else
if
(
!
shouldCloseAll
&&
!
shouldExpandAll
&&
!
discussion
.
expanded
)
{
dispatch
(
'
expandDiscussion
'
,
data
,
{
root
:
true
});
dispatch
(
'
expandDiscussion
'
,
data
,
{
root
:
true
});
}
}
});
});
...
...
spec/javascripts/diffs/store/actions_spec.js
View file @
c5a514de
...
@@ -191,4 +191,48 @@ describe('DiffsStoreActions', () => {
...
@@ -191,4 +191,48 @@ describe('DiffsStoreActions', () => {
);
);
});
});
});
});
describe
(
'
toggleFileDiscussions
'
,
()
=>
{
it
(
'
should dispatch collapseDiscussion when all discussions are expanded
'
,
()
=>
{
const
getters
=
{
getDiffFileDiscussions
:
jasmine
.
createSpy
().
and
.
returnValue
([{
id
:
1
}]),
diffHasAllExpandedDiscussions
:
jasmine
.
createSpy
().
and
.
returnValue
(
true
),
diffHasAllCollpasedDiscussions
:
jasmine
.
createSpy
().
and
.
returnValue
(
false
),
};
const
dispatch
=
jasmine
.
createSpy
(
'
dispatch
'
);
actions
.
toggleFileDiscussions
({
getters
,
dispatch
});
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
collapseDiscussion
'
,
{
discussionId
:
1
},
{
root
:
true
});
});
it
(
'
should dispatch expandDiscussion when all discussions are collapsed
'
,
()
=>
{
const
getters
=
{
getDiffFileDiscussions
:
jasmine
.
createSpy
().
and
.
returnValue
([{
id
:
1
}]),
diffHasAllExpandedDiscussions
:
jasmine
.
createSpy
().
and
.
returnValue
(
false
),
diffHasAllCollpasedDiscussions
:
jasmine
.
createSpy
().
and
.
returnValue
(
true
),
};
const
dispatch
=
jasmine
.
createSpy
();
actions
.
toggleFileDiscussions
({
getters
,
dispatch
});
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
expandDiscussion
'
,
{
discussionId
:
1
},
{
root
:
true
});
});
it
(
'
should dispatch expandDiscussion when some discussions are collapsed and others are expanded for the collapsed discussion
'
,
()
=>
{
const
getters
=
{
getDiffFileDiscussions
:
jasmine
.
createSpy
().
and
.
returnValue
([{
expanded
:
false
,
id
:
1
}]),
diffHasAllExpandedDiscussions
:
jasmine
.
createSpy
().
and
.
returnValue
(
false
),
diffHasAllCollpasedDiscussions
:
jasmine
.
createSpy
().
and
.
returnValue
(
false
),
};
const
dispatch
=
jasmine
.
createSpy
();
actions
.
toggleFileDiscussions
({
getters
,
dispatch
});
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
expandDiscussion
'
,
{
discussionId
:
1
},
{
root
:
true
});
});
});
});
});
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