Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
86b56868
Commit
86b56868
authored
Apr 28, 2020
by
Coung Ngo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Jest tests
Improve tests based on reviewer comments
parent
c80fac8b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
15 deletions
+20
-15
app/assets/javascripts/sidebar/components/participants/participants.vue
...ascripts/sidebar/components/participants/participants.vue
+1
-1
spec/frontend/sidebar/participants_spec.js
spec/frontend/sidebar/participants_spec.js
+18
-12
spec/frontend/sidebar/subscriptions_spec.js
spec/frontend/sidebar/subscriptions_spec.js
+1
-2
No files found.
app/assets/javascripts/sidebar/components/participants/participants.vue
View file @
86b56868
...
@@ -96,7 +96,7 @@ export default {
...
@@ -96,7 +96,7 @@ export default {
>
>
<i
class=
"fa fa-users"
aria-hidden=
"true"
>
</i>
<i
class=
"fa fa-users"
aria-hidden=
"true"
>
</i>
<gl-loading-icon
v-if=
"loading"
/>
<gl-loading-icon
v-if=
"loading"
/>
<span
v-else
class=
"js-participants-
collapsed-count"
>
{{
participantCount
}}
</span>
<span
v-else
data-testid=
"
collapsed-count"
>
{{
participantCount
}}
</span>
</div>
</div>
<div
v-if=
"showParticipantLabel"
class=
"title hide-collapsed"
>
<div
v-if=
"showParticipantLabel"
class=
"title hide-collapsed"
>
<gl-loading-icon
v-if=
"loading"
:inline=
"true"
/>
<gl-loading-icon
v-if=
"loading"
:inline=
"true"
/>
...
...
spec/frontend/sidebar/participants_spec.js
View file @
86b56868
...
@@ -19,6 +19,8 @@ describe('Participants', () => {
...
@@ -19,6 +19,8 @@ describe('Participants', () => {
const
getMoreParticipantsButton
=
()
=>
wrapper
.
find
(
'
button
'
);
const
getMoreParticipantsButton
=
()
=>
wrapper
.
find
(
'
button
'
);
const
getCollapsedParticipantsCount
=
()
=>
wrapper
.
find
(
'
[data-testid="collapsed-count"]
'
);
const
mountComponent
=
propsData
=>
const
mountComponent
=
propsData
=>
shallowMount
(
Participants
,
{
shallowMount
(
Participants
,
{
propsData
,
propsData
,
...
@@ -35,7 +37,15 @@ describe('Participants', () => {
...
@@ -35,7 +37,15 @@ describe('Participants', () => {
loading
:
true
,
loading
:
true
,
});
});
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
contains
(
GlLoadingIcon
)).
toBe
(
true
);
});
it
(
'
does not show loading spinner not loading
'
,
()
=>
{
wrapper
=
mountComponent
({
loading
:
false
,
});
expect
(
wrapper
.
contains
(
GlLoadingIcon
)).
toBe
(
false
);
});
});
it
(
'
shows participant count when given
'
,
()
=>
{
it
(
'
shows participant count when given
'
,
()
=>
{
...
@@ -44,9 +54,7 @@ describe('Participants', () => {
...
@@ -44,9 +54,7 @@ describe('Participants', () => {
participants
:
PARTICIPANT_LIST
,
participants
:
PARTICIPANT_LIST
,
});
});
expect
(
wrapper
.
find
(
'
.js-participants-collapsed-count
'
).
text
()).
toBe
(
expect
(
getCollapsedParticipantsCount
().
text
()).
toBe
(
`
${
PARTICIPANT_LIST
.
length
}
`
);
`
${
PARTICIPANT_LIST
.
length
}
`
,
);
});
});
it
(
'
shows full participant count when there are hidden participants
'
,
()
=>
{
it
(
'
shows full participant count when there are hidden participants
'
,
()
=>
{
...
@@ -56,9 +64,7 @@ describe('Participants', () => {
...
@@ -56,9 +64,7 @@ describe('Participants', () => {
numberOfLessParticipants
:
1
,
numberOfLessParticipants
:
1
,
});
});
expect
(
wrapper
.
find
(
'
.js-participants-collapsed-count
'
).
text
()).
toBe
(
expect
(
getCollapsedParticipantsCount
().
text
()).
toBe
(
`
${
PARTICIPANT_LIST
.
length
}
`
);
`
${
PARTICIPANT_LIST
.
length
}
`
,
);
});
});
});
});
...
@@ -68,7 +74,7 @@ describe('Participants', () => {
...
@@ -68,7 +74,7 @@ describe('Participants', () => {
loading
:
true
,
loading
:
true
,
});
});
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
(
)).
toBe
(
true
);
expect
(
wrapper
.
contains
(
GlLoadingIcon
)).
toBe
(
true
);
});
});
it
(
'
when only showing visible participants, shows an avatar only for each participant under the limit
'
,
()
=>
{
it
(
'
when only showing visible participants, shows an avatar only for each participant under the limit
'
,
()
=>
{
...
@@ -84,7 +90,7 @@ describe('Participants', () => {
...
@@ -84,7 +90,7 @@ describe('Participants', () => {
});
});
return
Vue
.
nextTick
().
then
(()
=>
{
return
Vue
.
nextTick
().
then
(()
=>
{
expect
(
wrapper
.
findAll
(
'
.participants-author
'
)
.
length
).
toBe
(
numberOfLessParticipants
);
expect
(
wrapper
.
findAll
(
'
.participants-author
'
)
).
toHaveLength
(
numberOfLessParticipants
);
});
});
});
});
...
@@ -100,7 +106,7 @@ describe('Participants', () => {
...
@@ -100,7 +106,7 @@ describe('Participants', () => {
});
});
return
Vue
.
nextTick
().
then
(()
=>
{
return
Vue
.
nextTick
().
then
(()
=>
{
expect
(
wrapper
.
findAll
(
'
.participants-author
'
)
.
length
).
toBe
(
PARTICIPANT_LIST
.
length
);
expect
(
wrapper
.
findAll
(
'
.participants-author
'
)
).
toHaveLength
(
PARTICIPANT_LIST
.
length
);
});
});
});
});
...
@@ -190,11 +196,11 @@ describe('Participants', () => {
...
@@ -190,11 +196,11 @@ describe('Participants', () => {
});
});
it
(
'
does not show sidebar collapsed icon
'
,
()
=>
{
it
(
'
does not show sidebar collapsed icon
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.sidebar-collapsed-icon
'
).
exists
(
)).
toBe
(
false
);
expect
(
wrapper
.
contains
(
'
.sidebar-collapsed-icon
'
)).
toBe
(
false
);
});
});
it
(
'
does not show participants label title
'
,
()
=>
{
it
(
'
does not show participants label title
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.title
'
).
exists
(
)).
toBe
(
false
);
expect
(
wrapper
.
contains
(
'
.title
'
)).
toBe
(
false
);
});
});
});
});
});
});
spec/frontend/sidebar/subscriptions_spec.js
View file @
86b56868
...
@@ -60,7 +60,6 @@ describe('Subscriptions', () => {
...
@@ -60,7 +60,6 @@ describe('Subscriptions', () => {
it
(
'
tracks the event when toggled
'
,
()
=>
{
it
(
'
tracks the event when toggled
'
,
()
=>
{
wrapper
=
mountComponent
({
subscribed
:
true
});
wrapper
=
mountComponent
({
subscribed
:
true
});
// const spy = mockTracking('_category_', wrapper.element, jest.spyOn);
const
wrapperTrackSpy
=
jest
.
spyOn
(
wrapper
.
vm
,
'
track
'
);
const
wrapperTrackSpy
=
jest
.
spyOn
(
wrapper
.
vm
,
'
track
'
);
wrapper
.
vm
.
toggleSubscription
();
wrapper
.
vm
.
toggleSubscription
();
...
@@ -101,7 +100,7 @@ describe('Subscriptions', () => {
...
@@ -101,7 +100,7 @@ describe('Subscriptions', () => {
});
});
it
(
'
does not render the toggle button
'
,
()
=>
{
it
(
'
does not render the toggle button
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-issuable-subscribe-button
'
).
exists
(
)).
toBe
(
false
);
expect
(
wrapper
.
contains
(
'
.js-issuable-subscribe-button
'
)).
toBe
(
false
);
});
});
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment