Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
57c32c7d
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,发现更多精彩内容 >>
未验证
提交
57c32c7d
编写于
7月 11, 2018
作者:
F
Filipa Lacerda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adds specs for getters in merge request vuex diff module
上级
135ead1d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
95 deletion
+30
-95
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/actions.js
+0
-1
spec/javascripts/diffs/components/diff_file_header_spec.js
spec/javascripts/diffs/components/diff_file_header_spec.js
+1
-1
spec/javascripts/diffs/store/getters_spec.js
spec/javascripts/diffs/store/getters_spec.js
+29
-93
未找到文件。
app/assets/javascripts/diffs/store/actions.js
浏览文件 @
57c32c7d
...
...
@@ -95,7 +95,6 @@ export const expandAllFiles = ({ commit }) => {
*/
export
const
toggleFileDiscussions
=
({
getters
,
dispatch
},
diff
)
=>
{
const
discussions
=
getters
.
getDiffFileDiscussions
(
diff
);
const
shouldCloseAll
=
getters
.
diffHasAllExpandedDiscussions
(
diff
);
const
shouldExpandAll
=
getters
.
diffHasAllCollpasedDiscussions
(
diff
);
...
...
spec/javascripts/diffs/components/diff_file_header_spec.js
浏览文件 @
57c32c7d
...
...
@@ -4,7 +4,7 @@ import diffsModule from '~/diffs/store/modules';
import
notesModule
from
'
~/notes/stores/modules
'
;
import
DiffFileHeader
from
'
~/diffs/components/diff_file_header.vue
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
mountComponent
,
{
mountComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
mountComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
const
discussionFixture
=
'
merge_requests/diff_discussion.json
'
;
...
...
spec/javascripts/diffs/store/getters_spec.js
浏览文件 @
57c32c7d
...
...
@@ -5,9 +5,20 @@ import discussion from '../mock_data/diff_discussions';
describe
(
'
Diffs Module Getters
'
,
()
=>
{
let
localState
;
let
discussionMock
;
let
discussionMock1
;
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
beforeEach
(()
=>
{
localState
=
state
();
discussionMock
=
Object
.
assign
({},
discussion
);
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock1
=
Object
.
assign
({},
discussion
);
discussionMock1
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
});
describe
(
'
isParallelView
'
,
()
=>
{
...
...
@@ -67,13 +78,6 @@ describe('Diffs Module Getters', () => {
describe
(
'
diffHasAllExpandedDiscussions
'
,
()
=>
{
it
(
'
returns true when all discussions are expanded
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
const
discussionMock
=
Object
.
assign
({},
discussion
);
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
expect
(
getters
.
diffHasAllExpandedDiscussions
(
localState
,
{
getDiffFileDiscussions
:
()
=>
[
discussionMock
,
discussionMock
],
...
...
@@ -82,10 +86,6 @@ describe('Diffs Module Getters', () => {
});
it
(
'
returns false when there are no discussions
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
expect
(
getters
.
diffHasAllExpandedDiscussions
(
localState
,
{
getDiffFileDiscussions
:
()
=>
[],
...
...
@@ -94,15 +94,6 @@ describe('Diffs Module Getters', () => {
});
it
(
'
returns false when one discussions is collapsed
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
const
discussionMock
=
Object
.
assign
({},
discussion
);
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
const
discussionMock1
=
Object
.
assign
({},
discussion
);
discussionMock1
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock1
.
expanded
=
false
;
expect
(
...
...
@@ -115,11 +106,6 @@ describe('Diffs Module Getters', () => {
describe
(
'
diffHasAllCollpasedDiscussions
'
,
()
=>
{
it
(
'
returns true when all discussions are collapsed
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
const
discussionMock
=
Object
.
assign
({},
discussion
);
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock
.
expanded
=
false
;
...
...
@@ -131,10 +117,6 @@ describe('Diffs Module Getters', () => {
});
it
(
'
returns false when there are no discussions
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
expect
(
getters
.
diffHasAllCollpasedDiscussions
(
localState
,
{
getDiffFileDiscussions
:
()
=>
[],
...
...
@@ -143,14 +125,6 @@ describe('Diffs Module Getters', () => {
});
it
(
'
returns false when one discussions is expanded
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
const
discussionMock
=
Object
.
assign
({},
discussion
);
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
const
discussionMock1
=
Object
.
assign
({},
discussion
);
discussionMock1
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock1
.
expanded
=
false
;
expect
(
...
...
@@ -163,14 +137,6 @@ describe('Diffs Module Getters', () => {
describe
(
'
diffHasExpandedDiscussions
'
,
()
=>
{
it
(
'
returns true when one of the discussions is expanded
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
const
discussionMock
=
Object
.
assign
({},
discussion
);
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
const
discussionMock1
=
Object
.
assign
({},
discussion
);
discussionMock1
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock1
.
expanded
=
false
;
expect
(
...
...
@@ -181,10 +147,6 @@ describe('Diffs Module Getters', () => {
});
it
(
'
returns false when there are no discussions
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
expect
(
getters
.
diffHasExpandedDiscussions
(
localState
,
{
getDiffFileDiscussions
:
()
=>
[]
})(
diffFileMock
,
...
...
@@ -193,17 +155,7 @@ describe('Diffs Module Getters', () => {
});
it
(
'
returns false when no discussion is expanded
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
const
discussionMock
=
Object
.
assign
({},
discussion
);
discussion
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock
.
expanded
=
false
;
const
discussionMock1
=
Object
.
assign
({},
discussion
);
discussionMock1
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock1
.
expanded
=
false
;
expect
(
...
...
@@ -214,38 +166,22 @@ describe('Diffs Module Getters', () => {
});
});
// describe('getDiffFileDiscussions', () => {
// it('returns an array with discussions when fileHash matches and the discussion belongs to a diff', () => {
// const diffFileMock = {
// fileHash: '9732849daca6ae818696d9575f5d1207d1a7f8bb',
// };
// const discussionMock = Object.assign({}, discussion);
// discussionMock.diff_file.file_hash = diffFileMock.fileHash;
// expect(
// getters.getDiffFileDiscussions(
// localState,
// {},
// {},
// { discussions: [discussionMock] },
// )(diffFileMock).length,
// ).toEqual(1);
// });
// it('returns an empty array when no discussions are found in the given diff', () => {
// const diffFileMock = {
// fileHash: '9732849daca6ae818696d9575f5d1207d1a7f8bb',
// };
// expect(
// getters.getDiffFileDiscussions(
// localState,
// {},
// {},
// { discussions: () => ([]) },
// )(diffFileMock).length,
// ).toEqual(0);
// });
// });
describe
(
'
getDiffFileDiscussions
'
,
()
=>
{
it
(
'
returns an array with discussions when fileHash matches and the discussion belongs to a diff
'
,
()
=>
{
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
expect
(
getters
.
getDiffFileDiscussions
(
localState
,
{},
{},
{
discussions
:
[
discussionMock
]
})(
diffFileMock
,
).
length
,
).
toEqual
(
1
);
});
it
(
'
returns an empty array when no discussions are found in the given diff
'
,
()
=>
{
expect
(
getters
.
getDiffFileDiscussions
(
localState
,
{},
{},
{
discussions
:
[]
})(
diffFileMock
)
.
length
,
).
toEqual
(
0
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录