Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
296f489d
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
296f489d
编写于
8月 01, 2018
作者:
A
André Luís
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reapply "Merge branch '48817-fix-mr-changes-discussion-navigation' into 'master'"
This reverts commit e0fe97ca4a506405af8e85368f2c69cda637e192.
上级
8047b00f
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
407 addition
and
68 deletion
+407
-68
app/assets/javascripts/diffs/components/diff_discussions.vue
app/assets/javascripts/diffs/components/diff_discussions.vue
+1
-0
app/assets/javascripts/notes/components/discussion_counter.vue
...ssets/javascripts/notes/components/discussion_counter.vue
+6
-22
app/assets/javascripts/notes/components/noteable_discussion.vue
...sets/javascripts/notes/components/noteable_discussion.vue
+21
-18
app/assets/javascripts/notes/mixins/discussion_navigation.js
app/assets/javascripts/notes/mixins/discussion_navigation.js
+29
-0
app/assets/javascripts/notes/stores/getters.js
app/assets/javascripts/notes/stores/getters.js
+85
-0
spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb
.../user_resolves_diff_notes_and_discussions_resolve_spec.rb
+3
-2
spec/javascripts/notes/components/discussion_counter_spec.js
spec/javascripts/notes/components/discussion_counter_spec.js
+1
-1
spec/javascripts/notes/components/noteable_discussion_spec.js
.../javascripts/notes/components/noteable_discussion_spec.js
+22
-25
spec/javascripts/notes/mock_data.js
spec/javascripts/notes/mock_data.js
+84
-0
spec/javascripts/notes/stores/getters_spec.js
spec/javascripts/notes/stores/getters_spec.js
+155
-0
未找到文件。
app/assets/javascripts/diffs/components/diff_discussions.vue
浏览文件 @
296f489d
...
...
@@ -30,6 +30,7 @@ export default {
:render-header=
"false"
:render-diff-file=
"false"
:always-expanded=
"true"
:discussions-by-diff-order=
"true"
/>
</ul>
</div>
...
...
app/assets/javascripts/notes/components/discussion_counter.vue
浏览文件 @
296f489d
...
...
@@ -5,19 +5,20 @@ import resolvedSvg from 'icons/_icon_status_success_solid.svg';
import
mrIssueSvg
from
'
icons/_icon_mr_issue.svg
'
;
import
nextDiscussionSvg
from
'
icons/_next_discussion.svg
'
;
import
{
pluralize
}
from
'
../../lib/utils/text_utility
'
;
import
{
scrollToElement
}
from
'
../../lib/utils/common_utils
'
;
import
discussionNavigation
from
'
../mixins/discussion_navigation
'
;
import
tooltip
from
'
../../vue_shared/directives/tooltip
'
;
export
default
{
directives
:
{
tooltip
,
},
mixins
:
[
discussionNavigation
],
computed
:
{
...
mapGetters
([
'
getUserData
'
,
'
getNoteableData
'
,
'
discussionCount
'
,
'
unresolvedDiscussions
'
,
'
firstUnresolvedDiscussionId
'
,
'
resolvedDiscussionCount
'
,
]),
isLoggedIn
()
{
...
...
@@ -35,11 +36,6 @@ export default {
resolveAllDiscussionsIssuePath
()
{
return
this
.
getNoteableData
.
create_issue_to_resolve_discussions_path
;
},
firstUnresolvedDiscussionId
()
{
const
item
=
this
.
unresolvedDiscussions
[
0
]
||
{};
return
item
.
id
;
},
},
created
()
{
this
.
resolveSvg
=
resolveSvg
;
...
...
@@ -50,22 +46,10 @@ export default {
methods
:
{
...
mapActions
([
'
expandDiscussion
'
]),
jumpToFirstUnresolvedDiscussion
()
{
const
discussionId
=
this
.
firstUnresolvedDiscussionId
;
if
(
!
discussionId
)
{
return
;
}
const
el
=
document
.
querySelector
(
`[data-discussion-id="
${
discussionId
}
"]`
);
const
activeTab
=
window
.
mrTabs
.
currentAction
;
if
(
activeTab
===
'
commits
'
||
activeTab
===
'
pipelines
'
)
{
window
.
mrTabs
.
activateTab
(
'
show
'
);
}
const
diffTab
=
window
.
mrTabs
.
currentAction
===
'
diffs
'
;
const
discussionId
=
this
.
firstUnresolvedDiscussionId
(
diffTab
);
if
(
el
)
{
this
.
expandDiscussion
({
discussionId
});
scrollToElement
(
el
);
}
this
.
jumpToDiscussion
(
discussionId
);
},
},
};
...
...
app/assets/javascripts/notes/components/noteable_discussion.vue
浏览文件 @
296f489d
<
script
>
import
_
from
'
underscore
'
;
import
{
mapActions
,
mapGetters
}
from
'
vuex
'
;
import
resolveDiscussionsSvg
from
'
icons/_icon_mr_issue.svg
'
;
import
nextDiscussionsSvg
from
'
icons/_next_discussion.svg
'
;
import
{
convertObjectPropsToCamelCase
,
scrollToElement
}
from
'
~/lib/utils/common_utils
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
truncateSha
}
from
'
~/lib/utils/text_utility
'
;
import
systemNote
from
'
~/vue_shared/components/notes/system_note.vue
'
;
import
{
s__
}
from
'
~/locale
'
;
...
...
@@ -21,6 +20,7 @@ import placeholderSystemNote from '../../vue_shared/components/notes/placeholder
import
autosave
from
'
../mixins/autosave
'
;
import
noteable
from
'
../mixins/noteable
'
;
import
resolvable
from
'
../mixins/resolvable
'
;
import
discussionNavigation
from
'
../mixins/discussion_navigation
'
;
import
tooltip
from
'
../../vue_shared/directives/tooltip
'
;
export
default
{
...
...
@@ -40,7 +40,7 @@ export default {
directives
:
{
tooltip
,
},
mixins
:
[
autosave
,
noteable
,
resolvable
],
mixins
:
[
autosave
,
noteable
,
resolvable
,
discussionNavigation
],
props
:
{
discussion
:
{
type
:
Object
,
...
...
@@ -61,6 +61,11 @@ export default {
required
:
false
,
default
:
false
,
},
discussionsByDiffOrder
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
data
()
{
return
{
...
...
@@ -75,7 +80,12 @@ export default {
'
discussionCount
'
,
'
resolvedDiscussionCount
'
,
'
allDiscussions
'
,
'
unresolvedDiscussionsIdsByDiff
'
,
'
unresolvedDiscussionsIdsByDate
'
,
'
unresolvedDiscussions
'
,
'
unresolvedDiscussionsIdsOrdered
'
,
'
nextUnresolvedDiscussionId
'
,
'
isLastUnresolvedDiscussion
'
,
]),
transformedDiscussion
()
{
return
{
...
...
@@ -126,6 +136,10 @@ export default {
hasMultipleUnresolvedDiscussions
()
{
return
this
.
unresolvedDiscussions
.
length
>
1
;
},
showJumpToNextDiscussion
()
{
return
this
.
hasMultipleUnresolvedDiscussions
&&
!
this
.
isLastUnresolvedDiscussion
(
this
.
discussion
.
id
,
this
.
discussionsByDiffOrder
);
},
shouldRenderDiffs
()
{
const
{
diffDiscussion
,
diffFile
}
=
this
.
transformedDiscussion
;
...
...
@@ -242,21 +256,10 @@ Please check your network connection and try again.`;
});
},
jumpToNextDiscussion
()
{
const
discussionIds
=
this
.
allDiscussions
.
map
(
d
=>
d
.
id
);
const
unresolvedIds
=
this
.
unresolvedDiscussions
.
map
(
d
=>
d
.
id
);
const
currentIndex
=
discussionIds
.
indexOf
(
this
.
discussion
.
id
);
const
remainingAfterCurrent
=
discussionIds
.
slice
(
currentIndex
+
1
);
const
nextIndex
=
_
.
findIndex
(
remainingAfterCurrent
,
id
=>
unresolvedIds
.
indexOf
(
id
)
>
-
1
);
if
(
nextIndex
>
-
1
)
{
const
nextId
=
remainingAfterCurrent
[
nextIndex
];
const
el
=
document
.
querySelector
(
`[data-discussion-id="
${
nextId
}
"]`
);
const
nextId
=
this
.
nextUnresolvedDiscussionId
(
this
.
discussion
.
id
,
this
.
discussionsByDiffOrder
);
if
(
el
)
{
this
.
expandDiscussion
({
discussionId
:
nextId
});
scrollToElement
(
el
);
}
}
this
.
jumpToDiscussion
(
nextId
);
},
},
};
...
...
@@ -398,7 +401,7 @@ Please check your network connection and try again.`;
</a>
</div>
<div
v-if=
"
hasMultipleUnresolvedDiscussions
"
v-if=
"
showJumpToNextDiscussion
"
class=
"btn-group"
role=
"group"
>
<button
...
...
app/assets/javascripts/notes/mixins/discussion_navigation.js
0 → 100644
浏览文件 @
296f489d
import
{
scrollToElement
}
from
'
~/lib/utils/common_utils
'
;
export
default
{
methods
:
{
jumpToDiscussion
(
id
)
{
if
(
id
)
{
const
activeTab
=
window
.
mrTabs
.
currentAction
;
const
selector
=
activeTab
===
'
diffs
'
?
`ul.notes[data-discussion-id="
${
id
}
"]`
:
`div.discussion[data-discussion-id="
${
id
}
"]`
;
const
el
=
document
.
querySelector
(
selector
);
if
(
activeTab
===
'
commits
'
||
activeTab
===
'
pipelines
'
)
{
window
.
mrTabs
.
activateTab
(
'
show
'
);
}
if
(
el
)
{
this
.
expandDiscussion
({
discussionId
:
id
});
scrollToElement
(
el
);
return
true
;
}
}
return
false
;
},
},
};
app/assets/javascripts/notes/stores/getters.js
浏览文件 @
296f489d
...
...
@@ -82,6 +82,9 @@ export const allDiscussions = (state, getters) => {
return
Object
.
values
(
resolved
).
concat
(
unresolved
);
};
export
const
allResolvableDiscussions
=
(
state
,
getters
)
=>
getters
.
allDiscussions
.
filter
(
d
=>
!
d
.
individual_note
&&
d
.
resolvable
);
export
const
resolvedDiscussionsById
=
state
=>
{
const
map
=
{};
...
...
@@ -98,6 +101,51 @@ export const resolvedDiscussionsById = state => {
return
map
;
};
// Gets Discussions IDs ordered by the date of their initial note
export
const
unresolvedDiscussionsIdsByDate
=
(
state
,
getters
)
=>
getters
.
allResolvableDiscussions
.
filter
(
d
=>
!
d
.
resolved
)
.
sort
((
a
,
b
)
=>
{
const
aDate
=
new
Date
(
a
.
notes
[
0
].
created_at
);
const
bDate
=
new
Date
(
b
.
notes
[
0
].
created_at
);
if
(
aDate
<
bDate
)
{
return
-
1
;
}
return
aDate
===
bDate
?
0
:
1
;
})
.
map
(
d
=>
d
.
id
);
// Gets Discussions IDs ordered by their position in the diff
//
// Sorts the array of resolvable yet unresolved discussions by
// comparing file names first. If file names are the same, compares
// line numbers.
export
const
unresolvedDiscussionsIdsByDiff
=
(
state
,
getters
)
=>
getters
.
allResolvableDiscussions
.
filter
(
d
=>
!
d
.
resolved
)
.
sort
((
a
,
b
)
=>
{
if
(
!
a
.
diff_file
||
!
b
.
diff_file
)
{
return
0
;
}
// Get file names comparison result
const
filenameComparison
=
a
.
diff_file
.
file_path
.
localeCompare
(
b
.
diff_file
.
file_path
);
// Get the line numbers, to compare within the same file
const
aLines
=
[
a
.
position
.
formatter
.
new_line
,
a
.
position
.
formatter
.
old_line
];
const
bLines
=
[
b
.
position
.
formatter
.
new_line
,
b
.
position
.
formatter
.
old_line
];
return
filenameComparison
<
0
||
(
filenameComparison
===
0
&&
// .max() because one of them might be zero (if removed/added)
Math
.
max
(
aLines
[
0
],
aLines
[
1
])
<
Math
.
max
(
bLines
[
0
],
bLines
[
1
]))
?
-
1
:
1
;
})
.
map
(
d
=>
d
.
id
);
export
const
resolvedDiscussionCount
=
(
state
,
getters
)
=>
{
const
resolvedMap
=
getters
.
resolvedDiscussionsById
;
...
...
@@ -114,5 +162,42 @@ export const discussionTabCounter = state => {
return
all
.
length
;
};
// Returns the list of discussion IDs ordered according to given parameter
// @param {Boolean} diffOrder - is ordered by diff?
export
const
unresolvedDiscussionsIdsOrdered
=
(
state
,
getters
)
=>
diffOrder
=>
{
if
(
diffOrder
)
{
return
getters
.
unresolvedDiscussionsIdsByDiff
;
}
return
getters
.
unresolvedDiscussionsIdsByDate
;
};
// Checks if a given discussion is the last in the current order (diff or date)
// @param {Boolean} discussionId - id of the discussion
// @param {Boolean} diffOrder - is ordered by diff?
export
const
isLastUnresolvedDiscussion
=
(
state
,
getters
)
=>
(
discussionId
,
diffOrder
)
=>
{
const
idsOrdered
=
getters
.
unresolvedDiscussionsIdsOrdered
(
diffOrder
);
const
lastDiscussionId
=
idsOrdered
[
idsOrdered
.
length
-
1
];
return
lastDiscussionId
===
discussionId
;
};
// Gets the ID of the discussion following the one provided, respecting order (diff or date)
// @param {Boolean} discussionId - id of the current discussion
// @param {Boolean} diffOrder - is ordered by diff?
export
const
nextUnresolvedDiscussionId
=
(
state
,
getters
)
=>
(
discussionId
,
diffOrder
)
=>
{
const
idsOrdered
=
getters
.
unresolvedDiscussionsIdsOrdered
(
diffOrder
);
const
currentIndex
=
idsOrdered
.
indexOf
(
discussionId
);
return
idsOrdered
.
slice
(
currentIndex
+
1
,
currentIndex
+
2
)[
0
];
};
// @param {Boolean} diffOrder - is ordered by diff?
export
const
firstUnresolvedDiscussionId
=
(
state
,
getters
)
=>
diffOrder
=>
{
if
(
diffOrder
)
{
return
getters
.
unresolvedDiscussionsIdsByDiff
[
0
];
}
return
getters
.
unresolvedDiscussionsIdsByDate
[
0
];
};
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export
default
()
=>
{};
spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb
浏览文件 @
296f489d
...
...
@@ -342,8 +342,9 @@ describe 'Merge request > User resolves diff notes and discussions', :js do
end
end
it
'shows jump to next discussion button'
do
expect
(
page
.
all
(
'.discussion-reply-holder'
,
count:
2
)).
to
all
(
have_selector
(
'.discussion-next-btn'
))
it
'shows jump to next discussion button, apart from the last one'
do
expect
(
page
).
to
have_selector
(
'.discussion-reply-holder'
,
count:
2
)
expect
(
page
).
to
have_selector
(
'.discussion-reply-holder .discussion-next-btn'
,
count:
1
)
end
it
'displays next discussion even if hidden'
do
...
...
spec/javascripts/notes/components/discussion_counter_spec.js
浏览文件 @
296f489d
...
...
@@ -46,7 +46,7 @@ describe('DiscussionCounter component', () => {
discussions
,
});
setFixtures
(
`
<div data-discussion-id="
${
firstDiscussionId
}
"></div>
<div
class="discussion"
data-discussion-id="
${
firstDiscussionId
}
"></div>
`
);
vm
.
jumpToFirstUnresolvedDiscussion
();
...
...
spec/javascripts/notes/components/noteable_discussion_spec.js
浏览文件 @
296f489d
...
...
@@ -14,6 +14,7 @@ describe('noteable_discussion component', () => {
preloadFixtures
(
discussionWithTwoUnresolvedNotes
);
beforeEach
(()
=>
{
window
.
mrTabs
=
{};
store
=
createStore
();
store
.
dispatch
(
'
setNoteableData
'
,
noteableDataMock
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
...
...
@@ -106,33 +107,29 @@ describe('noteable_discussion component', () => {
describe
(
'
methods
'
,
()
=>
{
describe
(
'
jumpToNextDiscussion
'
,
()
=>
{
it
(
'
expands next unresolved discussion
'
,
()
=>
{
spyOn
(
vm
,
'
expandDiscussion
'
).
and
.
stub
();
const
discussions
=
[
discussionMock
,
{
...
discussionMock
,
id
:
discussionMock
.
id
+
1
,
notes
:
[{
...
discussionMock
.
notes
[
0
],
resolvable
:
true
,
resolved
:
true
}],
},
{
...
discussionMock
,
id
:
discussionMock
.
id
+
2
,
notes
:
[{
...
discussionMock
.
notes
[
0
],
resolvable
:
true
,
resolved
:
false
}],
},
];
const
nextDiscussionId
=
discussionMock
.
id
+
2
;
store
.
replaceState
({
...
store
.
state
,
discussions
,
});
setFixtures
(
`
<div data-discussion-id="
${
nextDiscussionId
}
"></div>
`
);
it
(
'
expands next unresolved discussion
'
,
done
=>
{
const
discussion2
=
getJSONFixture
(
discussionWithTwoUnresolvedNotes
)[
0
];
discussion2
.
resolved
=
false
;
discussion2
.
id
=
'
next
'
;
// prepare this for being identified as next one (to be jumped to)
vm
.
$store
.
dispatch
(
'
setInitialNotes
'
,
[
discussionMock
,
discussion2
]);
window
.
mrTabs
.
currentAction
=
'
show
'
;
Vue
.
nextTick
()
.
then
(()
=>
{
spyOn
(
vm
,
'
expandDiscussion
'
).
and
.
stub
();
const
nextDiscussionId
=
discussion2
.
id
;
vm
.
jumpToNextDiscussion
();
setFixtures
(
`
<div class="discussion" data-discussion-id="
${
nextDiscussionId
}
"></div>
`
);
expect
(
vm
.
expandDiscussion
).
toHaveBeenCalledWith
({
discussionId
:
nextDiscussionId
});
vm
.
jumpToNextDiscussion
();
expect
(
vm
.
expandDiscussion
).
toHaveBeenCalledWith
({
discussionId
:
nextDiscussionId
});
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
...
...
spec/javascripts/notes/mock_data.js
浏览文件 @
296f489d
...
...
@@ -1168,3 +1168,87 @@ export const collapsedSystemNotes = [
diff_discussion
:
false
,
},
];
export
const
discussion1
=
{
id
:
'
abc1
'
,
resolvable
:
true
,
resolved
:
false
,
diff_file
:
{
file_path
:
'
about.md
'
,
},
position
:
{
formatter
:
{
new_line
:
50
,
old_line
:
null
,
},
},
notes
:
[
{
created_at
:
'
2018-07-04T16:25:41.749Z
'
,
},
],
};
export
const
resolvedDiscussion1
=
{
id
:
'
abc1
'
,
resolvable
:
true
,
resolved
:
true
,
diff_file
:
{
file_path
:
'
about.md
'
,
},
position
:
{
formatter
:
{
new_line
:
50
,
old_line
:
null
,
},
},
notes
:
[
{
created_at
:
'
2018-07-04T16:25:41.749Z
'
,
},
],
};
export
const
discussion2
=
{
id
:
'
abc2
'
,
resolvable
:
true
,
resolved
:
false
,
diff_file
:
{
file_path
:
'
README.md
'
,
},
position
:
{
formatter
:
{
new_line
:
null
,
old_line
:
20
,
},
},
notes
:
[
{
created_at
:
'
2018-07-04T12:05:41.749Z
'
,
},
],
};
export
const
discussion3
=
{
id
:
'
abc3
'
,
resolvable
:
true
,
resolved
:
false
,
diff_file
:
{
file_path
:
'
README.md
'
,
},
position
:
{
formatter
:
{
new_line
:
21
,
old_line
:
null
,
},
},
notes
:
[
{
created_at
:
'
2018-07-05T17:25:41.749Z
'
,
},
],
};
export
const
unresolvableDiscussion
=
{
resolvable
:
false
,
};
spec/javascripts/notes/stores/getters_spec.js
浏览文件 @
296f489d
...
...
@@ -5,6 +5,11 @@ import {
noteableDataMock
,
individualNote
,
collapseNotesMock
,
discussion1
,
discussion2
,
discussion3
,
resolvedDiscussion1
,
unresolvableDiscussion
,
}
from
'
../mock_data
'
;
const
discussionWithTwoUnresolvedNotes
=
'
merge_requests/resolved_diff_discussion.json
'
;
...
...
@@ -109,4 +114,154 @@ describe('Getters Notes Store', () => {
expect
(
getters
.
isNotesFetched
(
state
)).
toBeFalsy
();
});
});
describe
(
'
allResolvableDiscussions
'
,
()
=>
{
it
(
'
should return only resolvable discussions in same order
'
,
()
=>
{
const
localGetters
=
{
allDiscussions
:
[
discussion3
,
unresolvableDiscussion
,
discussion1
,
unresolvableDiscussion
,
discussion2
,
],
};
expect
(
getters
.
allResolvableDiscussions
(
state
,
localGetters
)).
toEqual
([
discussion3
,
discussion1
,
discussion2
,
]);
});
it
(
'
should return empty array if there are no resolvable discussions
'
,
()
=>
{
const
localGetters
=
{
allDiscussions
:
[
unresolvableDiscussion
,
unresolvableDiscussion
],
};
expect
(
getters
.
allResolvableDiscussions
(
state
,
localGetters
)).
toEqual
([]);
});
});
describe
(
'
unresolvedDiscussionsIdsByDiff
'
,
()
=>
{
it
(
'
should return all discussions IDs in diff order
'
,
()
=>
{
const
localGetters
=
{
allResolvableDiscussions
:
[
discussion3
,
discussion1
,
discussion2
],
};
expect
(
getters
.
unresolvedDiscussionsIdsByDiff
(
state
,
localGetters
)).
toEqual
([
'
abc1
'
,
'
abc2
'
,
'
abc3
'
,
]);
});
it
(
'
should return empty array if all discussions have been resolved
'
,
()
=>
{
const
localGetters
=
{
allResolvableDiscussions
:
[
resolvedDiscussion1
],
};
expect
(
getters
.
unresolvedDiscussionsIdsByDiff
(
state
,
localGetters
)).
toEqual
([]);
});
});
describe
(
'
unresolvedDiscussionsIdsByDate
'
,
()
=>
{
it
(
'
should return all discussions in date ascending order
'
,
()
=>
{
const
localGetters
=
{
allResolvableDiscussions
:
[
discussion3
,
discussion1
,
discussion2
],
};
expect
(
getters
.
unresolvedDiscussionsIdsByDate
(
state
,
localGetters
)).
toEqual
([
'
abc2
'
,
'
abc1
'
,
'
abc3
'
,
]);
});
it
(
'
should return empty array if all discussions have been resolved
'
,
()
=>
{
const
localGetters
=
{
allResolvableDiscussions
:
[
resolvedDiscussion1
],
};
expect
(
getters
.
unresolvedDiscussionsIdsByDate
(
state
,
localGetters
)).
toEqual
([]);
});
});
describe
(
'
unresolvedDiscussionsIdsOrdered
'
,
()
=>
{
const
localGetters
=
{
unresolvedDiscussionsIdsByDate
:
[
'
123
'
,
'
456
'
],
unresolvedDiscussionsIdsByDiff
:
[
'
abc
'
,
'
def
'
],
};
it
(
'
should return IDs ordered by diff when diffOrder param is true
'
,
()
=>
{
expect
(
getters
.
unresolvedDiscussionsIdsOrdered
(
state
,
localGetters
)(
true
)).
toEqual
([
'
abc
'
,
'
def
'
,
]);
});
it
(
'
should return IDs ordered by date when diffOrder param is not true
'
,
()
=>
{
expect
(
getters
.
unresolvedDiscussionsIdsOrdered
(
state
,
localGetters
)(
false
)).
toEqual
([
'
123
'
,
'
456
'
,
]);
expect
(
getters
.
unresolvedDiscussionsIdsOrdered
(
state
,
localGetters
)(
undefined
)).
toEqual
([
'
123
'
,
'
456
'
,
]);
});
});
describe
(
'
isLastUnresolvedDiscussion
'
,
()
=>
{
const
localGetters
=
{
unresolvedDiscussionsIdsOrdered
:
()
=>
[
'
123
'
,
'
456
'
,
'
789
'
],
};
it
(
'
should return true if the discussion id provided is the last
'
,
()
=>
{
expect
(
getters
.
isLastUnresolvedDiscussion
(
state
,
localGetters
)(
'
789
'
)).
toBe
(
true
);
});
it
(
'
should return false if the discussion id provided is not the last
'
,
()
=>
{
expect
(
getters
.
isLastUnresolvedDiscussion
(
state
,
localGetters
)(
'
123
'
)).
toBe
(
false
);
expect
(
getters
.
isLastUnresolvedDiscussion
(
state
,
localGetters
)(
'
456
'
)).
toBe
(
false
);
});
});
describe
(
'
nextUnresolvedDiscussionId
'
,
()
=>
{
const
localGetters
=
{
unresolvedDiscussionsIdsOrdered
:
()
=>
[
'
123
'
,
'
456
'
,
'
789
'
],
};
it
(
'
should return the ID of the discussion after the ID provided
'
,
()
=>
{
expect
(
getters
.
nextUnresolvedDiscussionId
(
state
,
localGetters
)(
'
123
'
)).
toBe
(
'
456
'
);
expect
(
getters
.
nextUnresolvedDiscussionId
(
state
,
localGetters
)(
'
456
'
)).
toBe
(
'
789
'
);
expect
(
getters
.
nextUnresolvedDiscussionId
(
state
,
localGetters
)(
'
789
'
)).
toBe
(
undefined
);
});
});
describe
(
'
firstUnresolvedDiscussionId
'
,
()
=>
{
const
localGetters
=
{
unresolvedDiscussionsIdsByDate
:
[
'
123
'
,
'
456
'
],
unresolvedDiscussionsIdsByDiff
:
[
'
abc
'
,
'
def
'
],
};
it
(
'
should return the first discussion id by diff when diffOrder param is true
'
,
()
=>
{
expect
(
getters
.
firstUnresolvedDiscussionId
(
state
,
localGetters
)(
true
)).
toBe
(
'
abc
'
);
});
it
(
'
should return the first discussion id by date when diffOrder param is not true
'
,
()
=>
{
expect
(
getters
.
firstUnresolvedDiscussionId
(
state
,
localGetters
)(
false
)).
toBe
(
'
123
'
);
expect
(
getters
.
firstUnresolvedDiscussionId
(
state
,
localGetters
)(
undefined
)).
toBe
(
'
123
'
);
});
it
(
'
should be falsy if all discussions are resolved
'
,
()
=>
{
const
localGettersFalsy
=
{
unresolvedDiscussionsIdsByDiff
:
[],
unresolvedDiscussionsIdsByDate
:
[],
};
expect
(
getters
.
firstUnresolvedDiscussionId
(
state
,
localGettersFalsy
)(
true
)).
toBeFalsy
();
expect
(
getters
.
firstUnresolvedDiscussionId
(
state
,
localGettersFalsy
)(
false
)).
toBeFalsy
();
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录