Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
982da16b
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,发现更多精彩内容 >>
提交
982da16b
编写于
9月 07, 2018
作者:
T
Tim Zallmann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Made the discussion tests artificial to have them stable, mocked RAF + RIC
上级
b8ecb2c7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
98 addition
and
46 deletion
+98
-46
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/actions.js
+1
-0
spec/javascripts/diffs/store/actions_spec.js
spec/javascripts/diffs/store/actions_spec.js
+97
-46
未找到文件。
app/assets/javascripts/diffs/store/actions.js
浏览文件 @
982da16b
...
...
@@ -65,6 +65,7 @@ export const assignDiscussionsToDiff = ({ state, commit }, allLineDiscussions) =
export
const
removeDiscussionsFromDiff
=
({
state
,
commit
},
removeDiscussion
)
=>
{
const
{
fileHash
}
=
removeDiscussion
;
const
selectedFile
=
state
.
diffFiles
.
find
(
file
=>
file
.
fileHash
===
fileHash
);
if
(
selectedFile
)
{
const
targetLine
=
selectedFile
.
parallelDiffLines
.
find
(
line
=>
...
...
spec/javascripts/diffs/store/actions_spec.js
浏览文件 @
982da16b
...
...
@@ -10,10 +10,27 @@ import * as types from '~/diffs/store/mutation_types';
import
{
reduceDiscussionsToLineCodes
}
from
'
~/notes/stores/utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
testAction
from
'
../../helpers/vuex_action_helper
'
;
import
mockFile
from
'
../mock_data/diff_file
'
;
import
mockDiscussion
from
'
../mock_data/diff_discussions
'
;
describe
(
'
DiffsStoreActions
'
,
()
=>
{
const
originalMethods
=
{
requestAnimationFrame
:
global
.
requestAnimationFrame
,
requestIdleCallback
:
global
.
requestIdleCallback
,
};
beforeEach
(()
=>
{
[
'
requestAnimationFrame
'
,
'
requestIdleCallback
'
].
forEach
(
method
=>
{
global
[
method
]
=
cb
=>
{
cb
();
};
});
});
afterEach
(()
=>
{
[
'
requestAnimationFrame
'
,
'
requestIdleCallback
'
].
forEach
(
method
=>
{
global
[
method
]
=
originalMethods
[
method
];
});
});
describe
(
'
setBaseConfig
'
,
()
=>
{
it
(
'
should set given endpoint and project path
'
,
done
=>
{
const
endpoint
=
'
/diffs/set/endpoint
'
;
...
...
@@ -58,8 +75,40 @@ describe('DiffsStoreActions', () => {
describe
(
'
assignDiscussionsToDiff
'
,
()
=>
{
it
(
'
should merge discussions into diffs
'
,
done
=>
{
const
state
=
{
diffFiles
:
[
Object
.
assign
({},
mockFile
)]
};
const
singleDiscussion
=
Object
.
assign
({},
mockDiscussion
);
const
state
=
{
diffFiles
:
[
{
fileHash
:
'
ABC
'
,
parallelDiffLines
:
[
{
left
:
{
lineCode
:
'
ABC_1_1
'
,
discussions
:
[],
},
right
:
{
lineCode
:
'
ABC_1_1
'
,
discussions
:
[],
},
},
],
highlightedDiffLines
:
[
{
lineCode
:
'
ABC_1_1
'
,
discussions
:
[],
},
],
},
],
};
const
singleDiscussion
=
{
line_code
:
'
ABC_1_1
'
,
diff_discussion
:
{},
diff_file
:
{
file_hash
:
'
ABC
'
,
},
resolvable
:
true
,
};
const
discussions
=
reduceDiscussionsToLineCodes
([
singleDiscussion
]);
testAction
(
...
...
@@ -71,32 +120,20 @@ describe('DiffsStoreActions', () => {
type
:
types
.
SET_LINE_DISCUSSIONS
,
payload
:
{
line
:
{
lineCode
:
'
1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_2
'
,
type
:
'
new
'
,
oldLine
:
null
,
newLine
:
2
,
lineCode
:
'
ABC_1_1
'
,
discussions
:
[],
text
:
'
+<span id="LC2" class="line" lang="plaintext"></span>
\n
'
,
richText
:
'
<span id="LC2" class="line" lang="plaintext"></span>
\n
'
,
metaData
:
null
,
},
discussions
:
discussions
[
'
1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_2
'
],
discussions
:
[
singleDiscussion
],
},
},
{
type
:
types
.
SET_LINE_DISCUSSIONS
,
payload
:
{
line
:
{
lineCode
:
'
1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_2
'
,
type
:
'
new
'
,
oldLine
:
null
,
newLine
:
2
,
lineCode
:
'
ABC_1_1
'
,
discussions
:
[],
text
:
'
+<span id="LC2" class="line" lang="plaintext"></span>
\n
'
,
richText
:
'
+<span id="LC2" class="line" lang="plaintext"></span>
\n
'
,
metaData
:
null
,
},
discussions
:
discussions
[
'
1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_2
'
],
discussions
:
[
singleDiscussion
],
},
},
],
...
...
@@ -110,10 +147,39 @@ describe('DiffsStoreActions', () => {
describe
(
'
removeDiscussionsFromDiff
'
,
()
=>
{
it
(
'
should remove discussions from diffs
'
,
done
=>
{
const
state
=
{
diffFiles
:
[
Object
.
assign
({},
mockFile
)]
};
const
singleDiscussion
=
Object
.
assign
({},
mockDiscussion
);
reduceDiscussionsToLineCodes
([
singleDiscussion
]);
const
state
=
{
diffFiles
:
[
{
fileHash
:
'
ABC
'
,
parallelDiffLines
:
[
{
left
:
{
lineCode
:
'
ABC_1_1
'
,
discussions
:
[
{
id
:
1
,
},
],
},
right
:
{
lineCode
:
'
ABC_1_1
'
,
discussions
:
[],
},
},
],
highlightedDiffLines
:
[
{
lineCode
:
'
ABC_1_1
'
,
discussions
:
[],
},
],
},
],
};
const
singleDiscussion
=
{
fileHash
:
'
ABC
'
,
line_code
:
'
ABC_1_1
'
,
};
testAction
(
actions
.
removeDiscussionsFromDiff
,
...
...
@@ -123,27 +189,19 @@ describe('DiffsStoreActions', () => {
{
type
:
types
.
REMOVE_LINE_DISCUSSIONS
,
payload
:
{
lineCode
:
'
1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_2
'
,
type
:
'
new
'
,
oldLine
:
null
,
newLine
:
2
,
discussions
:
[],
text
:
'
+<span id="LC2" class="line" lang="plaintext"></span>
\n
'
,
richText
:
'
<span id="LC2" class="line" lang="plaintext"></span>
\n
'
,
metaData
:
null
,
lineCode
:
'
ABC_1_1
'
,
discussions
:
[
{
id
:
1
,
},
],
},
},
{
type
:
types
.
REMOVE_LINE_DISCUSSIONS
,
payload
:
{
lineCode
:
'
1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_2
'
,
type
:
'
new
'
,
oldLine
:
null
,
newLine
:
2
,
lineCode
:
'
ABC_1_1
'
,
discussions
:
[],
text
:
'
+<span id="LC2" class="line" lang="plaintext"></span>
\n
'
,
richText
:
'
+<span id="LC2" class="line" lang="plaintext"></span>
\n
'
,
metaData
:
null
,
},
},
],
...
...
@@ -157,11 +215,6 @@ describe('DiffsStoreActions', () => {
describe
(
'
startRenderDiffsQueue
'
,
()
=>
{
it
(
'
should set all files to RENDER_FILE
'
,
done
=>
{
const
actualRAF
=
global
.
requestAnimationFrame
;
global
.
requestAnimationFrame
=
cb
=>
{
cb
();
};
const
state
=
{
diffFiles
:
[
{
...
...
@@ -187,8 +240,6 @@ describe('DiffsStoreActions', () => {
actions
.
startRenderDiffsQueue
({
state
,
commit
:
pseudoCommit
})
.
then
(()
=>
{
global
.
requestAnimationFrame
=
actualRAF
;
expect
(
state
.
diffFiles
[
0
].
renderIt
).
toBeTruthy
();
expect
(
state
.
diffFiles
[
1
].
renderIt
).
toBeTruthy
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录