Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
082b868e
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,发现更多精彩内容 >>
提交
082b868e
编写于
5月 04, 2017
作者:
R
Regis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix js specs
上级
3af533f7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
71 deletion
+23
-71
app/assets/javascripts/issue_show/actions/tasks.js
app/assets/javascripts/issue_show/actions/tasks.js
+12
-12
spec/javascripts/issue_show/issue_title_description_spec.js
spec/javascripts/issue_show/issue_title_description_spec.js
+11
-11
spec/javascripts/issue_spec.js
spec/javascripts/issue_spec.js
+0
-48
未找到文件。
app/assets/javascripts/issue_show/actions/tasks.js
浏览文件 @
082b868e
export
default
(
api
Data
,
tasks
)
=>
{
export
default
(
newState
Data
,
tasks
)
=>
{
const
$tasks
=
$
(
'
#task_status
'
);
const
$tasksShort
=
$
(
'
#task_status_short
'
);
const
$issueableHeader
=
$
(
'
.issuable-header
'
);
const
tasksStates
=
{
api
:
null
,
tasks
:
null
};
const
tasksStates
=
{
newState
:
null
,
currentState
:
null
};
if
(
$tasks
.
length
===
0
)
{
if
(
!
(
api
Data
.
task_status
.
indexOf
(
'
0 of 0
'
)
===
0
))
{
$issueableHeader
.
append
(
`<span id="task_status">
${
api
Data
.
task_status
}
</span>`
);
if
(
!
(
newState
Data
.
task_status
.
indexOf
(
'
0 of 0
'
)
===
0
))
{
$issueableHeader
.
append
(
`<span id="task_status">
${
newState
Data
.
task_status
}
</span>`
);
}
else
{
$issueableHeader
.
append
(
'
<span id="task_status"></span>
'
);
}
}
else
{
tasksStates
.
api
=
api
Data
.
task_status
.
indexOf
(
'
0 of 0
'
)
===
0
;
tasksStates
.
tasks
=
tasks
.
indexOf
(
'
0 of 0
'
)
===
0
;
tasksStates
.
newState
=
newState
Data
.
task_status
.
indexOf
(
'
0 of 0
'
)
===
0
;
tasksStates
.
currentState
=
tasks
.
indexOf
(
'
0 of 0
'
)
===
0
;
}
if
(
$tasks
&&
!
tasksStates
.
api
)
{
$tasks
.
text
(
api
Data
.
task_status
);
$tasksShort
.
text
(
api
Data
.
task_status
);
}
else
if
(
tasksStates
.
tasks
)
{
$issueableHeader
.
append
(
`<span id="task_status">
${
api
Data
.
task_status
}
</span>`
);
}
else
if
(
tasksStates
.
api
)
{
if
(
$tasks
&&
!
tasksStates
.
newState
)
{
$tasks
.
text
(
newState
Data
.
task_status
);
$tasksShort
.
text
(
newState
Data
.
task_status
);
}
else
if
(
tasksStates
.
currentState
)
{
$issueableHeader
.
append
(
`<span id="task_status">
${
newState
Data
.
task_status
}
</span>`
);
}
else
if
(
tasksStates
.
newState
)
{
$tasks
.
remove
();
$tasksShort
.
remove
();
}
...
...
spec/javascripts/issue_show/issue_title_description_spec.js
浏览文件 @
082b868e
...
...
@@ -2,7 +2,7 @@ import Vue from 'vue';
import
$
from
'
jquery
'
;
import
'
~/render_math
'
;
import
'
~/render_gfm
'
;
import
issueTitle
from
'
~/issue_show/issue_title_description.vue
'
;
import
issueTitle
Description
from
'
~/issue_show/issue_title_description.vue
'
;
import
issueShowData
from
'
./mock_data
'
;
window
.
$
=
$
;
...
...
@@ -11,18 +11,18 @@ const issueShowInterceptor = data => (request, next) => {
next
(
request
.
respondWith
(
JSON
.
stringify
(
data
),
{
status
:
200
,
headers
:
{
'
POLL-INTERVAL
'
:
1
0
,
'
POLL-INTERVAL
'
:
1
,
},
}));
};
describe
(
'
Issue Title
'
,
()
=>
{
const
comps
=
{
IssueTitleComponent
:
{},
}
;
document
.
body
.
innerHTML
=
'
<span id="task_status"></span>
'
;
let
IssueTitleDescriptionComponent
;
beforeEach
(()
=>
{
comps
.
IssueTitleComponent
=
Vue
.
extend
(
issueTitle
);
IssueTitleDescriptionComponent
=
Vue
.
extend
(
issueTitleDescription
);
});
afterEach
(()
=>
{
...
...
@@ -32,14 +32,14 @@ describe('Issue Title', () => {
it
(
'
should render a title/description and update title/description on update
'
,
(
done
)
=>
{
Vue
.
http
.
interceptors
.
push
(
issueShowInterceptor
(
issueShowData
.
initialRequest
));
const
issueShowComponent
=
new
comps
.
IssueTitle
Component
({
const
issueShowComponent
=
new
IssueTitleDescription
Component
({
propsData
:
{
can
description
:
'
.css-stuff
'
,
can
UpdateIssue
:
'
.css-stuff
'
,
endpoint
:
'
/gitlab-org/gitlab-shell/issues/9/rendered_title
'
,
},
}).
$mount
();
// need setTimeout because
actual setTimeout in code :P
// need setTimeout because
of api call/v-html
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
title
'
).
innerText
).
toContain
(
'
this is a title (#1)
'
);
expect
(
issueShowComponent
.
$el
.
querySelector
(
'
.title
'
).
innerHTML
).
toContain
(
'
<p>this is a title</p>
'
);
...
...
@@ -55,8 +55,8 @@ describe('Issue Title', () => {
expect
(
issueShowComponent
.
$el
.
querySelector
(
'
.js-task-list-field
'
).
innerText
).
toContain
(
'
42
'
);
done
();
}
,
20
);
}
,
10
);
});
});
// 10ms is just long enough for the update hook to fire
});
});
spec/javascripts/issue_spec.js
浏览文件 @
082b868e
/* eslint-disable space-before-function-paren, one-var, one-var-declaration-per-line, no-use-before-define, comma-dangle, max-len */
import
Issue
from
'
~/issue
'
;
import
Vue
from
'
vue
'
;
import
'
~/render_math
'
;
import
'
~/render_gfm
'
;
import
IssueTitle
from
'
~/issue_show/issue_title_description.vue
'
;
import
issueShowData
from
'
./issue_show/mock_data
'
;
require
(
'
~/lib/utils/text_utility
'
);
...
...
@@ -81,52 +76,9 @@ describe('Issue', function() {
}
describe
(
'
task lists
'
,
function
()
{
const
issueShowInterceptor
=
data
=>
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
(
data
),
{
status
:
200
,
}));
};
beforeEach
(
function
()
{
loadFixtures
(
'
issues/issue-with-task-list.html.raw
'
);
this
.
issue
=
new
Issue
();
Vue
.
http
.
interceptors
.
push
(
issueShowInterceptor
(
issueShowData
.
issueSpecRequest
));
});
afterEach
(
function
()
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
issueShowInterceptor
);
});
it
(
'
modifies the Markdown field
'
,
function
(
done
)
{
// gotta actually render it for jquery to find elements
const
vm
=
new
Vue
({
el
:
document
.
querySelector
(
'
.issue-title-entrypoint
'
),
components
:
{
IssueTitle
,
},
render
:
createElement
=>
createElement
(
IssueTitle
,
{
props
:
{
candescription
:
'
.js-task-list-container
'
,
endpoint
:
'
/gitlab-org/gitlab-shell/issues/9/rendered_title
'
,
},
}),
});
setTimeout
(()
=>
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
stub
();
const
description
=
'
<li class="task-list-item enabled"><input type="checkbox" class="task-list-item-checkbox"> Task List Item</li>
'
;
expect
(
document
.
querySelector
(
'
title
'
).
innerText
).
toContain
(
'
this is a title (#1)
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.title
'
).
innerHTML
).
toContain
(
'
<p>this is a title</p>
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.wiki
'
).
innerHTML
).
toContain
(
description
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-task-list-field
'
).
value
).
toContain
(
'
- [ ] Task List Item
'
);
// somehow the dom does not have a closest `.js-task-list.field` to the `.task-list-item-checkbox`
$
(
'
input[type=checkbox]
'
).
attr
(
'
checked
'
,
true
).
trigger
(
'
change
'
);
expect
(
$
(
'
.js-task-list-field
'
).
val
()).
toBe
(
'
- [x] Task List Item
'
);
done
();
},
10
);
});
it
(
'
submits an ajax request on tasklist:changed
'
,
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录