Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
608a6484
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,发现更多精彩内容 >>
未验证
提交
608a6484
编写于
3月 27, 2018
作者:
P
Phil Hughes
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added specs
上级
babb90a7
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
229 addition
and
16 deletion
+229
-16
app/assets/javascripts/ide/stores/mutations/file.js
app/assets/javascripts/ide/stores/mutations/file.js
+16
-10
spec/javascripts/ide/components/commit_sidebar/list_item_spec.js
...vascripts/ide/components/commit_sidebar/list_item_spec.js
+9
-6
spec/javascripts/ide/stores/actions/file_spec.js
spec/javascripts/ide/stores/actions/file_spec.js
+125
-0
spec/javascripts/ide/stores/mutations/file_spec.js
spec/javascripts/ide/stores/mutations/file_spec.js
+79
-0
未找到文件。
app/assets/javascripts/ide/stores/mutations/file.js
浏览文件 @
608a6484
...
...
@@ -114,24 +114,30 @@ export default {
}),
});
}
else
{
Object
.
assign
(
state
,
{
entries
:
Object
.
assign
(
state
.
entries
,
{
[
file
.
path
]:
Object
.
assign
(
state
.
entries
[
file
.
path
],
{
opened
:
false
,
}),
}),
openFiles
:
state
.
openFiles
.
map
(
f
=>
{
const
openFile
=
state
.
openFiles
.
find
(
f
=>
f
.
path
===
file
.
path
);
const
openFiles
=
state
.
openFiles
.
concat
(
openFile
?
null
:
file
)
.
filter
(
f
=>
f
)
.
reduce
((
acc
,
f
)
=>
{
if
(
f
.
path
===
file
.
path
)
{
return
{
return
acc
.
concat
(
{
...
f
,
active
:
true
,
pending
:
true
,
key
:
`pending-
${
f
.
key
}
`
,
};
}
)
;
}
return
f
;
return
acc
.
concat
(
f
);
},
[]);
Object
.
assign
(
state
,
{
entries
:
Object
.
assign
(
state
.
entries
,
{
[
file
.
path
]:
Object
.
assign
(
state
.
entries
[
file
.
path
],
{
opened
:
false
,
}),
}),
openFiles
,
});
}
},
...
...
spec/javascripts/ide/components/commit_sidebar/list_item_spec.js
浏览文件 @
608a6484
...
...
@@ -14,6 +14,8 @@ describe('Multi-file editor commit sidebar list item', () => {
f
=
file
(
'
test-file
'
);
store
.
state
.
entries
[
f
.
path
]
=
f
;
vm
=
createComponentWithStore
(
Component
,
store
,
{
file
:
f
,
}).
$mount
();
...
...
@@ -24,9 +26,7 @@ describe('Multi-file editor commit sidebar list item', () => {
});
it
(
'
renders file path
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.multi-file-commit-list-path
'
).
textContent
.
trim
(),
).
toBe
(
f
.
path
);
expect
(
vm
.
$el
.
querySelector
(
'
.multi-file-commit-list-path
'
).
textContent
.
trim
()).
toBe
(
f
.
path
);
});
it
(
'
calls discardFileChanges when clicking discard button
'
,
()
=>
{
...
...
@@ -39,7 +39,6 @@ describe('Multi-file editor commit sidebar list item', () => {
it
(
'
opens a closed file in the editor when clicking the file path
'
,
done
=>
{
spyOn
(
vm
,
'
openFileInEditor
'
).
and
.
callThrough
();
spyOn
(
vm
,
'
updateViewer
'
).
and
.
callThrough
();
spyOn
(
router
,
'
push
'
);
vm
.
$el
.
querySelector
(
'
.multi-file-commit-list-path
'
).
click
();
...
...
@@ -52,14 +51,18 @@ describe('Multi-file editor commit sidebar list item', () => {
});
});
it
(
'
calls updateViewer with diff when clicking file
'
,
()
=>
{
it
(
'
calls updateViewer with diff when clicking file
'
,
done
=>
{
spyOn
(
vm
,
'
openFileInEditor
'
).
and
.
callThrough
();
spyOn
(
vm
,
'
updateViewer
'
).
and
.
callThrough
();
spyOn
(
router
,
'
push
'
);
vm
.
$el
.
querySelector
(
'
.multi-file-commit-list-path
'
).
click
();
setTimeout
(()
=>
{
expect
(
vm
.
updateViewer
).
toHaveBeenCalledWith
(
'
diff
'
);
done
();
});
});
describe
(
'
computed
'
,
()
=>
{
...
...
spec/javascripts/ide/stores/actions/file_spec.js
浏览文件 @
608a6484
...
...
@@ -74,6 +74,22 @@ describe('Multi-file store file actions', () => {
})
.
catch
(
done
.
fail
);
});
it
(
'
removes file if it pending
'
,
done
=>
{
store
.
state
.
openFiles
.
push
({
...
localFile
,
pending
:
true
,
});
store
.
dispatch
(
'
closeFile
'
,
localFile
)
.
then
(()
=>
{
expect
(
store
.
state
.
openFiles
.
length
).
toBe
(
0
);
done
();
})
.
catch
(
done
.
fail
);
});
});
describe
(
'
setFileActive
'
,
()
=>
{
...
...
@@ -418,4 +434,113 @@ describe('Multi-file store file actions', () => {
.
catch
(
done
.
fail
);
});
});
describe
(
'
openPendingTab
'
,
()
=>
{
let
f
;
beforeEach
(()
=>
{
f
=
{
...
file
(),
projectId
:
'
123
'
,
};
store
.
state
.
entries
[
f
.
path
]
=
f
;
});
it
(
'
makes file pending in openFiles
'
,
done
=>
{
store
.
dispatch
(
'
openPendingTab
'
,
f
)
.
then
(()
=>
{
expect
(
store
.
state
.
openFiles
[
0
].
pending
).
toBe
(
true
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
returns true when opened
'
,
done
=>
{
store
.
dispatch
(
'
openPendingTab
'
,
f
)
.
then
(
added
=>
{
expect
(
added
).
toBe
(
true
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
pushes router URL when added
'
,
done
=>
{
store
.
state
.
currentBranchId
=
'
master
'
;
store
.
dispatch
(
'
openPendingTab
'
,
f
)
.
then
(()
=>
{
expect
(
router
.
push
).
toHaveBeenCalledWith
(
'
/project/123/tree/master/
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
calls scrollToTab
'
,
done
=>
{
const
scrollToTabSpy
=
jasmine
.
createSpy
(
'
scrollToTab
'
);
const
oldScrollToTab
=
store
.
_actions
.
scrollToTab
;
// eslint-disable-line
store
.
_actions
.
scrollToTab
=
[
scrollToTabSpy
];
// eslint-disable-line
store
.
dispatch
(
'
openPendingTab
'
,
f
)
.
then
(()
=>
{
expect
(
scrollToTabSpy
).
toHaveBeenCalled
();
store
.
_actions
.
scrollToTab
=
oldScrollToTab
;
// eslint-disable-line
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
returns false when passed in file is active & viewer is diff
'
,
done
=>
{
f
.
active
=
true
;
store
.
state
.
openFiles
.
push
(
f
);
store
.
state
.
viewer
=
'
diff
'
;
store
.
dispatch
(
'
openPendingTab
'
,
f
)
.
then
(
added
=>
{
expect
(
added
).
toBe
(
false
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
describe
(
'
removePendingTab
'
,
()
=>
{
let
f
;
beforeEach
(()
=>
{
spyOn
(
eventHub
,
'
$emit
'
);
f
=
{
...
file
(
'
pendingFile
'
),
pending
:
true
,
};
});
it
(
'
removes pending file from open files
'
,
done
=>
{
store
.
state
.
openFiles
.
push
(
f
);
store
.
dispatch
(
'
removePendingTab
'
,
f
)
.
then
(()
=>
{
expect
(
store
.
state
.
openFiles
.
length
).
toBe
(
0
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
emits event to dispose model
'
,
done
=>
{
store
.
dispatch
(
'
removePendingTab
'
,
f
)
.
then
(()
=>
{
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
`editor.update.model.dispose.
${
f
.
key
}
`
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
spec/javascripts/ide/stores/mutations/file_spec.js
浏览文件 @
608a6484
...
...
@@ -22,6 +22,20 @@ describe('Multi-file store file mutations', () => {
expect
(
localFile
.
active
).
toBeTruthy
();
});
it
(
'
sets pending tab as not active
'
,
()
=>
{
localState
.
openFiles
.
push
({
...
localFile
,
pending
:
true
,
});
mutations
.
SET_FILE_ACTIVE
(
localState
,
{
path
:
localFile
.
path
,
active
:
true
,
});
expect
(
localState
.
openFiles
[
0
].
active
).
toBe
(
false
);
});
});
describe
(
'
TOGGLE_FILE_OPEN
'
,
()
=>
{
...
...
@@ -154,4 +168,69 @@ describe('Multi-file store file mutations', () => {
expect
(
localFile
.
changed
).
toBeTruthy
();
});
});
describe
(
'
ADD_PENDING_TAB
'
,
()
=>
{
beforeEach
(()
=>
{
const
f
=
{
...
file
(
'
openFile
'
),
path
:
'
openFile
'
,
active
:
true
,
opened
:
true
,
};
localState
.
entries
[
f
.
path
]
=
f
;
localState
.
openFiles
.
push
(
f
);
});
it
(
'
adds file into openFiles as pending
'
,
()
=>
{
mutations
.
ADD_PENDING_TAB
(
localState
,
localFile
);
expect
(
localState
.
openFiles
.
length
).
toBe
(
2
);
expect
(
localState
.
openFiles
[
1
].
pending
).
toBe
(
true
);
expect
(
localState
.
openFiles
[
1
].
key
).
toBe
(
`pending-
${
localFile
.
key
}
`
);
});
it
(
'
updates open file to pending
'
,
()
=>
{
mutations
.
ADD_PENDING_TAB
(
localState
,
localState
.
openFiles
[
0
]);
expect
(
localState
.
openFiles
.
length
).
toBe
(
1
);
});
it
(
'
updates pending open file to active
'
,
()
=>
{
localState
.
openFiles
.
push
({
...
localFile
,
pending
:
true
,
});
mutations
.
ADD_PENDING_TAB
(
localState
,
localFile
);
expect
(
localState
.
openFiles
[
1
].
pending
).
toBe
(
true
);
expect
(
localState
.
openFiles
[
1
].
active
).
toBe
(
true
);
});
it
(
'
sets all openFiles to not active
'
,
()
=>
{
mutations
.
ADD_PENDING_TAB
(
localState
,
localFile
);
expect
(
localState
.
openFiles
.
length
).
toBe
(
2
);
localState
.
openFiles
.
forEach
(
f
=>
{
if
(
f
.
pending
)
{
expect
(
f
.
active
).
toBe
(
true
);
}
else
{
expect
(
f
.
active
).
toBe
(
false
);
}
});
});
});
describe
(
'
REMOVE_PENDING_TAB
'
,
()
=>
{
it
(
'
removes pending tab from openFiles
'
,
()
=>
{
localFile
.
key
=
'
testing
'
;
localState
.
openFiles
.
push
(
localFile
);
mutations
.
REMOVE_PENDING_TAB
(
localState
,
localFile
);
expect
(
localState
.
openFiles
.
length
).
toBe
(
0
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录