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
032a00e1
Commit
032a00e1
authored
Jan 18, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
ba5726cf
2f3a0040
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
15 deletions
+50
-15
app/assets/javascripts/vue_shared/components/user_avatar/user_avatar_list.vue
...ts/vue_shared/components/user_avatar/user_avatar_list.vue
+7
-1
app/assets/javascripts/vuex_shared/modules/modal/actions.js
app/assets/javascripts/vuex_shared/modules/modal/actions.js
+3
-0
spec/javascripts/vue_shared/components/user_avatar/user_avatar_list_spec.js
...ue_shared/components/user_avatar/user_avatar_list_spec.js
+40
-14
No files found.
app/assets/javascripts/vue_shared/components/user_avatar/user_avatar_list.vue
View file @
032a00e1
...
...
@@ -23,6 +23,11 @@ export default {
required
:
false
,
default
:
20
,
},
emptyText
:
{
type
:
String
,
required
:
false
,
default
:
__
(
'
None
'
),
},
},
data
()
{
return
{
...
...
@@ -65,7 +70,8 @@ export default {
</
script
>
<
template
>
<div>
<div
v-if=
"!items.length"
>
{{
emptyText
}}
</div>
<div
v-else
>
<user-avatar-link
v-for=
"item in visibleItems"
:key=
"item.id"
...
...
app/assets/javascripts/vuex_shared/modules/modal/actions.js
View file @
032a00e1
...
...
@@ -15,3 +15,6 @@ export const show = ({ commit }) => {
export
const
hide
=
({
commit
})
=>
{
commit
(
types
.
HIDE
);
};
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export
default
()
=>
{};
spec/javascripts/vue_shared/components/user_avatar/user_avatar_list_spec.js
View file @
032a00e1
...
...
@@ -6,6 +6,8 @@ import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link
const
TEST_IMAGE_SIZE
=
7
;
const
TEST_BREAKPOINT
=
5
;
const
TEST_EMPTY_MESSAGE
=
'
Lorem ipsum empty
'
;
const
DEFAULT_EMPTY_MESSAGE
=
'
None
'
;
const
createUser
=
id
=>
({
id
,
...
...
@@ -21,14 +23,19 @@ const createList = n =>
const
localVue
=
createLocalVue
();
describe
(
'
UserAvatarList
'
,
()
=>
{
let
props
Data
;
let
props
;
let
wrapper
;
const
factory
=
options
=>
{
const
factory
=
(
options
=
{})
=>
{
const
propsData
=
{
...
props
,
...
options
.
propsData
,
};
wrapper
=
shallowMount
(
localVue
.
extend
(
UserAvatarList
),
{
...
options
,
localVue
,
propsData
,
...
options
,
});
};
...
...
@@ -38,28 +45,47 @@ describe('UserAvatarList', () => {
};
beforeEach
(()
=>
{
props
Data
=
{
imgSize
:
TEST_IMAGE_SIZE
};
props
=
{
imgSize
:
TEST_IMAGE_SIZE
};
});
afterEach
(()
=>
{
wrapper
.
destroy
();
});
describe
(
'
empty text
'
,
()
=>
{
it
(
'
shows when items are empty
'
,
()
=>
{
factory
({
propsData
:
{
items
:
[]
}
});
expect
(
wrapper
.
text
()).
toContain
(
DEFAULT_EMPTY_MESSAGE
);
});
it
(
'
does not show when items are not empty
'
,
()
=>
{
factory
({
propsData
:
{
items
:
createList
(
1
)
}
});
expect
(
wrapper
.
text
()).
not
.
toContain
(
DEFAULT_EMPTY_MESSAGE
);
});
it
(
'
can be set in props
'
,
()
=>
{
factory
({
propsData
:
{
items
:
[],
emptyText
:
TEST_EMPTY_MESSAGE
}
});
expect
(
wrapper
.
text
()).
toContain
(
TEST_EMPTY_MESSAGE
);
});
});
describe
(
'
with no breakpoint
'
,
()
=>
{
beforeEach
(()
=>
{
props
Data
.
breakpoint
=
0
;
props
.
breakpoint
=
0
;
});
it
(
'
renders avatars
'
,
()
=>
{
const
items
=
createList
(
20
);
propsData
.
items
=
items
;
factory
();
factory
({
propsData
:
{
items
}
});
const
links
=
wrapper
.
findAll
(
UserAvatarLink
);
const
linkProps
=
links
.
wrappers
.
map
(
x
=>
x
.
props
());
expect
(
linkProps
).
toEqual
(
propsData
.
items
.
map
(
x
=>
items
.
map
(
x
=>
jasmine
.
objectContaining
({
linkHref
:
x
.
web_url
,
imgSrc
:
x
.
avatar_url
,
...
...
@@ -74,8 +100,8 @@ describe('UserAvatarList', () => {
describe
(
'
with breakpoint and length equal to breakpoint
'
,
()
=>
{
beforeEach
(()
=>
{
props
Data
.
breakpoint
=
TEST_BREAKPOINT
;
props
Data
.
items
=
createList
(
TEST_BREAKPOINT
);
props
.
breakpoint
=
TEST_BREAKPOINT
;
props
.
items
=
createList
(
TEST_BREAKPOINT
);
});
it
(
'
renders all avatars if length is <= breakpoint
'
,
()
=>
{
...
...
@@ -83,7 +109,7 @@ describe('UserAvatarList', () => {
const
links
=
wrapper
.
findAll
(
UserAvatarLink
);
expect
(
links
.
length
).
toEqual
(
props
Data
.
items
.
length
);
expect
(
links
.
length
).
toEqual
(
props
.
items
.
length
);
});
it
(
'
does not show button
'
,
()
=>
{
...
...
@@ -95,8 +121,8 @@ describe('UserAvatarList', () => {
describe
(
'
with breakpoint and length greater than breakpoint
'
,
()
=>
{
beforeEach
(()
=>
{
props
Data
.
breakpoint
=
TEST_BREAKPOINT
;
props
Data
.
items
=
createList
(
TEST_BREAKPOINT
+
1
);
props
.
breakpoint
=
TEST_BREAKPOINT
;
props
.
items
=
createList
(
TEST_BREAKPOINT
+
1
);
});
it
(
'
renders avatars up to breakpoint
'
,
()
=>
{
...
...
@@ -116,7 +142,7 @@ describe('UserAvatarList', () => {
it
(
'
renders all avatars
'
,
()
=>
{
const
links
=
wrapper
.
findAll
(
UserAvatarLink
);
expect
(
links
.
length
).
toEqual
(
props
Data
.
items
.
length
);
expect
(
links
.
length
).
toEqual
(
props
.
items
.
length
);
});
it
(
'
with collapse clicked, it renders avatars up to breakpoint
'
,
()
=>
{
...
...
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