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
c66555e9
Commit
c66555e9
authored
Mar 22, 2022
by
Olena Horal-Koretska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests
parent
13113ca4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
26 deletions
+70
-26
spec/frontend/vue_shared/components/user_avatar/user_avatar_image_new_spec.js
...ared/components/user_avatar/user_avatar_image_new_spec.js
+23
-9
spec/frontend/vue_shared/components/user_avatar/user_avatar_image_old_spec.js
...ared/components/user_avatar/user_avatar_image_old_spec.js
+22
-17
spec/frontend/vue_shared/components/user_avatar/user_avatar_list_spec.js
...ue_shared/components/user_avatar/user_avatar_list_spec.js
+25
-0
No files found.
spec/frontend/vue_shared/components/user_avatar/user_avatar_image_new_spec.js
View file @
c66555e9
...
@@ -109,19 +109,33 @@ describe('User Avatar Image Component', () => {
...
@@ -109,19 +109,33 @@ describe('User Avatar Image Component', () => {
default
:
[
'
Action!
'
],
default
:
[
'
Action!
'
],
};
};
describe
(
'
when `tooltipText` is provided and no default slot
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
wrapper
=
shallowMount
(
UserAvatarImage
,
{
wrapper
=
shallowMount
(
UserAvatarImage
,
{
propsData
:
PROVIDED_PROPS
,
propsData
:
{
...
PROVIDED_PROPS
},
});
});
it
(
'
renders the tooltip with `tooltipText` as content
'
,
()
=>
{
expect
(
wrapper
.
findComponent
(
GlTooltip
).
text
()).
toBe
(
PROVIDED_PROPS
.
tooltipText
);
});
});
describe
(
'
when `tooltipText` and default slot is provided
'
,
()
=>
{
beforeEach
(()
=>
{
wrapper
=
shallowMount
(
UserAvatarImage
,
{
propsData
:
{
...
PROVIDED_PROPS
},
slots
,
slots
,
});
});
});
});
it
(
'
renders the tooltip slot
'
,
()
=>
{
it
(
'
does not render `tooltipText` inside the tooltip
'
,
()
=>
{
expect
(
wrapper
.
findComponent
(
GlTooltip
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
findComponent
(
GlTooltip
).
text
()).
not
.
toBe
(
PROVIDED_PROPS
.
tooltipText
);
});
});
it
(
'
renders the tooltip conten
t
'
,
()
=>
{
it
(
'
renders the content provided via default slo
t
'
,
()
=>
{
expect
(
wrapper
.
findComponent
(
GlTooltip
).
text
()).
toContain
(
slots
.
default
[
0
]);
expect
(
wrapper
.
findComponent
(
GlTooltip
).
text
()).
toContain
(
slots
.
default
[
0
]);
});
});
});
});
});
});
});
spec/frontend/vue_shared/components/user_avatar/user_avatar_image_old_spec.js
View file @
c66555e9
...
@@ -90,33 +90,38 @@ describe('User Avatar Image Component', () => {
...
@@ -90,33 +90,38 @@ describe('User Avatar Image Component', () => {
});
});
});
});
describe
(
'
dynamic tooltip content
'
,
()
=>
{
describe
(
'
Dynamic tooltip content
'
,
()
=>
{
const
props
=
PROVIDED_PROPS
;
const
slots
=
{
const
slots
=
{
default
:
[
'
Action!
'
],
default
:
[
'
Action!
'
],
};
};
describe
(
'
when `tooltipText` is provided and no default slot
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
wrapper
=
shallowMount
(
UserAvatarImage
,
{
wrapper
=
shallowMount
(
UserAvatarImage
,
{
propsData
:
{
props
},
propsData
:
{
...
PROVIDED_PROPS
},
slots
,
});
});
});
});
it
(
'
renders the tooltip slot
'
,
()
=>
{
it
(
'
renders the tooltip with `tooltipText` as content
'
,
()
=>
{
expect
(
wrapper
.
findComponent
(
GlTooltip
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
findComponent
(
GlTooltip
).
text
()).
toBe
(
PROVIDED_PROPS
.
tooltipText
);
});
});
});
it
(
'
renders the tooltip content
'
,
()
=>
{
describe
(
'
when `tooltipText` and default slot is provided
'
,
()
=>
{
expect
(
wrapper
.
findComponent
(
GlTooltip
).
text
()).
toContain
(
slots
.
default
[
0
]);
beforeEach
(()
=>
{
wrapper
=
shallowMount
(
UserAvatarImage
,
{
propsData
:
{
...
PROVIDED_PROPS
},
slots
,
});
});
});
it
(
'
does not render tooltip data attributes on avatar image
'
,
()
=>
{
it
(
'
does not render `tooltipText` inside the tooltip
'
,
()
=>
{
const
avatarImg
=
wrapper
.
find
(
'
img
'
);
expect
(
wrapper
.
findComponent
(
GlTooltip
).
text
()).
not
.
toBe
(
PROVIDED_PROPS
.
tooltipText
);
});
expect
(
avatarImg
.
attributes
(
'
title
'
)).
toBeFalsy
();
it
(
'
renders the content provided via default slot
'
,
()
=>
{
expect
(
avatarImg
.
attributes
(
'
data-placement
'
)).
not
.
toBeDefined
(
);
expect
(
wrapper
.
findComponent
(
GlTooltip
).
text
()).
toContain
(
slots
.
default
[
0
]
);
expect
(
avatarImg
.
attributes
(
'
data-container
'
)).
not
.
toBeDefined
(
);
}
);
});
});
});
});
});
});
spec/frontend/vue_shared/components/user_avatar/user_avatar_list_spec.js
View file @
c66555e9
...
@@ -153,4 +153,29 @@ describe('UserAvatarList', () => {
...
@@ -153,4 +153,29 @@ describe('UserAvatarList', () => {
});
});
});
});
});
});
describe
(
'
additional styling for the image
'
,
()
=>
{
it
(
'
should not add CSS class when feature flag `glAvatarForAllUserAvatars` is disabled
'
,
()
=>
{
factory
({
propsData
:
{
items
:
createList
(
1
)
},
});
const
link
=
wrapper
.
findComponent
(
UserAvatarLink
);
expect
(
link
.
props
(
'
imgCssClasses
'
)).
not
.
toBe
(
'
gl-mr-3
'
);
});
it
(
'
should add CSS class when feature flag `glAvatarForAllUserAvatars` is enabled
'
,
()
=>
{
factory
({
propsData
:
{
items
:
createList
(
1
)
},
provide
:
{
glFeatures
:
{
glAvatarForAllUserAvatars
:
true
,
},
},
});
const
link
=
wrapper
.
findComponent
(
UserAvatarLink
);
expect
(
link
.
props
(
'
imgCssClasses
'
)).
toBe
(
'
gl-mr-3
'
);
});
});
});
});
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