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
6037c62d
Commit
6037c62d
authored
Dec 20, 2019
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add find and create helpers to user_popover_spec
parent
0050baad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
88 deletions
+43
-88
spec/frontend/vue_shared/components/user_popover/user_popover_spec.js
...d/vue_shared/components/user_popover/user_popover_spec.js
+43
-88
No files found.
spec/frontend/vue_shared/components/user_popover/user_popover_spec.js
View file @
6037c62d
...
@@ -29,23 +29,40 @@ describe('User Popover Component', () => {
...
@@ -29,23 +29,40 @@ describe('User Popover Component', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
const
findUserStatus
=
()
=>
wrapper
.
find
(
'
.js-user-status
'
);
const
findTarget
=
()
=>
document
.
querySelector
(
'
.js-user-link
'
);
const
createWrapper
=
(
props
=
{},
options
=
{})
=>
{
wrapper
=
shallowMount
(
UserPopover
,
{
propsData
:
{
...
DEFAULT_PROPS
,
target
:
findTarget
(),
...
props
,
},
sync
:
false
,
...
options
,
});
};
describe
(
'
Empty
'
,
()
=>
{
describe
(
'
Empty
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
wrapper
=
shallowMount
(
UserPopover
,
{
createWrapper
(
propsData
:
{
{},
target
:
document
.
querySelector
(
'
.js-user-link
'
),
{
user
:
{
propsData
:
{
name
:
null
,
target
:
findTarget
(),
username
:
null
,
user
:
{
location
:
null
,
name
:
null
,
bio
:
null
,
username
:
null
,
organization
:
null
,
location
:
null
,
status
:
null
,
bio
:
null
,
organization
:
null
,
status
:
null
,
},
},
},
attachToDocument
:
true
,
},
},
attachToDocument
:
true
,
);
sync
:
false
,
});
});
});
it
(
'
should return skeleton loaders
'
,
()
=>
{
it
(
'
should return skeleton loaders
'
,
()
=>
{
...
@@ -55,13 +72,7 @@ describe('User Popover Component', () => {
...
@@ -55,13 +72,7 @@ describe('User Popover Component', () => {
describe
(
'
basic data
'
,
()
=>
{
describe
(
'
basic data
'
,
()
=>
{
it
(
'
should show basic fields
'
,
()
=>
{
it
(
'
should show basic fields
'
,
()
=>
{
wrapper
=
shallowMount
(
UserPopover
,
{
createWrapper
();
propsData
:
{
...
DEFAULT_PROPS
,
target
:
document
.
querySelector
(
'
.js-user-link
'
),
},
sync
:
false
,
});
expect
(
wrapper
.
text
()).
toContain
(
DEFAULT_PROPS
.
user
.
name
);
expect
(
wrapper
.
text
()).
toContain
(
DEFAULT_PROPS
.
user
.
name
);
expect
(
wrapper
.
text
()).
toContain
(
DEFAULT_PROPS
.
user
.
username
);
expect
(
wrapper
.
text
()).
toContain
(
DEFAULT_PROPS
.
user
.
username
);
...
@@ -79,14 +90,7 @@ describe('User Popover Component', () => {
...
@@ -79,14 +90,7 @@ describe('User Popover Component', () => {
it
(
'
should show only bio if no organization is available
'
,
()
=>
{
it
(
'
should show only bio if no organization is available
'
,
()
=>
{
const
user
=
{
...
DEFAULT_PROPS
.
user
,
bio
:
'
Engineer
'
};
const
user
=
{
...
DEFAULT_PROPS
.
user
,
bio
:
'
Engineer
'
};
wrapper
=
shallowMount
(
UserPopover
,
{
createWrapper
({
user
});
propsData
:
{
...
DEFAULT_PROPS
,
user
,
target
:
document
.
querySelector
(
'
.js-user-link
'
),
},
sync
:
false
,
});
expect
(
wrapper
.
text
()).
toContain
(
'
Engineer
'
);
expect
(
wrapper
.
text
()).
toContain
(
'
Engineer
'
);
});
});
...
@@ -94,14 +98,7 @@ describe('User Popover Component', () => {
...
@@ -94,14 +98,7 @@ describe('User Popover Component', () => {
it
(
'
should show only organization if no bio is available
'
,
()
=>
{
it
(
'
should show only organization if no bio is available
'
,
()
=>
{
const
user
=
{
...
DEFAULT_PROPS
.
user
,
organization
:
'
GitLab
'
};
const
user
=
{
...
DEFAULT_PROPS
.
user
,
organization
:
'
GitLab
'
};
wrapper
=
shallowMount
(
UserPopover
,
{
createWrapper
({
user
});
propsData
:
{
...
DEFAULT_PROPS
,
user
,
target
:
document
.
querySelector
(
'
.js-user-link
'
),
},
sync
:
false
,
});
expect
(
wrapper
.
text
()).
toContain
(
'
GitLab
'
);
expect
(
wrapper
.
text
()).
toContain
(
'
GitLab
'
);
});
});
...
@@ -109,14 +106,7 @@ describe('User Popover Component', () => {
...
@@ -109,14 +106,7 @@ describe('User Popover Component', () => {
it
(
'
should display bio and organization in separate lines
'
,
()
=>
{
it
(
'
should display bio and organization in separate lines
'
,
()
=>
{
const
user
=
{
...
DEFAULT_PROPS
.
user
,
bio
:
'
Engineer
'
,
organization
:
'
GitLab
'
};
const
user
=
{
...
DEFAULT_PROPS
.
user
,
bio
:
'
Engineer
'
,
organization
:
'
GitLab
'
};
wrapper
=
shallowMount
(
UserPopover
,
{
createWrapper
({
user
});
propsData
:
{
...
DEFAULT_PROPS
,
user
,
target
:
document
.
querySelector
(
'
.js-user-link
'
),
},
sync
:
false
,
});
expect
(
wrapper
.
find
(
'
.js-bio
'
).
text
()).
toContain
(
'
Engineer
'
);
expect
(
wrapper
.
find
(
'
.js-bio
'
).
text
()).
toContain
(
'
Engineer
'
);
expect
(
wrapper
.
find
(
'
.js-organization
'
).
text
()).
toContain
(
'
GitLab
'
);
expect
(
wrapper
.
find
(
'
.js-organization
'
).
text
()).
toContain
(
'
GitLab
'
);
...
@@ -129,14 +119,7 @@ describe('User Popover Component', () => {
...
@@ -129,14 +119,7 @@ describe('User Popover Component', () => {
organization
:
'
Me & my <funky> Company
'
,
organization
:
'
Me & my <funky> Company
'
,
};
};
wrapper
=
shallowMount
(
UserPopover
,
{
createWrapper
({
user
});
propsData
:
{
...
DEFAULT_PROPS
,
user
,
target
:
document
.
querySelector
(
'
.js-user-link
'
),
},
sync
:
false
,
});
expect
(
wrapper
.
find
(
'
.js-bio
'
).
text
()).
toContain
(
'
Manager & Team Lead
'
);
expect
(
wrapper
.
find
(
'
.js-bio
'
).
text
()).
toContain
(
'
Manager & Team Lead
'
);
expect
(
wrapper
.
find
(
'
.js-organization
'
).
text
()).
toContain
(
'
Me & my <funky> Company
'
);
expect
(
wrapper
.
find
(
'
.js-organization
'
).
text
()).
toContain
(
'
Me & my <funky> Company
'
);
...
@@ -157,16 +140,9 @@ describe('User Popover Component', () => {
...
@@ -157,16 +140,9 @@ describe('User Popover Component', () => {
it
(
'
should show only message
'
,
()
=>
{
it
(
'
should show only message
'
,
()
=>
{
const
user
=
{
...
DEFAULT_PROPS
.
user
,
status
:
{
message_html
:
'
Hello World
'
}
};
const
user
=
{
...
DEFAULT_PROPS
.
user
,
status
:
{
message_html
:
'
Hello World
'
}
};
wrapper
=
shallowMount
(
UserPopover
,
{
createWrapper
({
user
});
propsData
:
{
...
DEFAULT_PROPS
,
user
,
target
:
document
.
querySelector
(
'
.js-user-link
'
),
},
sync
:
false
,
});
expect
(
wrapper
.
find
(
'
.js-user-status
'
).
exists
()).
toBe
(
true
);
expect
(
findUserStatus
(
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
text
()).
toContain
(
'
Hello World
'
);
expect
(
wrapper
.
text
()).
toContain
(
'
Hello World
'
);
});
});
...
@@ -176,16 +152,9 @@ describe('User Popover Component', () => {
...
@@ -176,16 +152,9 @@ describe('User Popover Component', () => {
status
:
{
emoji
:
'
basketball_player
'
,
message_html
:
'
Hello World
'
},
status
:
{
emoji
:
'
basketball_player
'
,
message_html
:
'
Hello World
'
},
};
};
wrapper
=
shallowMount
(
UserPopover
,
{
createWrapper
({
user
});
propsData
:
{
...
DEFAULT_PROPS
,
user
,
target
:
document
.
querySelector
(
'
.js-user-link
'
),
},
sync
:
false
,
});
expect
(
wrapper
.
find
(
'
.js-user-status
'
).
exists
()).
toBe
(
true
);
expect
(
findUserStatus
(
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
text
()).
toContain
(
'
Hello World
'
);
expect
(
wrapper
.
text
()).
toContain
(
'
Hello World
'
);
expect
(
wrapper
.
html
()).
toContain
(
'
<gl-emoji data-name="basketball_player"
'
);
expect
(
wrapper
.
html
()).
toContain
(
'
<gl-emoji data-name="basketball_player"
'
);
});
});
...
@@ -193,31 +162,17 @@ describe('User Popover Component', () => {
...
@@ -193,31 +162,17 @@ describe('User Popover Component', () => {
it
(
'
hides the div when status is null
'
,
()
=>
{
it
(
'
hides the div when status is null
'
,
()
=>
{
const
user
=
{
...
DEFAULT_PROPS
.
user
,
status
:
null
};
const
user
=
{
...
DEFAULT_PROPS
.
user
,
status
:
null
};
wrapper
=
shallowMount
(
UserPopover
,
{
createWrapper
({
user
});
propsData
:
{
...
DEFAULT_PROPS
,
user
,
target
:
document
.
querySelector
(
'
.js-user-link
'
),
},
sync
:
false
,
});
expect
(
wrapper
.
find
(
'
.js-user-status
'
).
exists
()).
toBe
(
false
);
expect
(
findUserStatus
(
).
exists
()).
toBe
(
false
);
});
});
it
(
'
hides the div when status is empty
'
,
()
=>
{
it
(
'
hides the div when status is empty
'
,
()
=>
{
const
user
=
{
...
DEFAULT_PROPS
.
user
,
status
:
{
emoji
:
''
,
message_html
:
''
}
};
const
user
=
{
...
DEFAULT_PROPS
.
user
,
status
:
{
emoji
:
''
,
message_html
:
''
}
};
wrapper
=
shallowMount
(
UserPopover
,
{
createWrapper
({
user
});
propsData
:
{
...
DEFAULT_PROPS
,
user
,
target
:
document
.
querySelector
(
'
.js-user-link
'
),
},
sync
:
false
,
});
expect
(
wrapper
.
find
(
'
.js-user-status
'
).
exists
()).
toBe
(
false
);
expect
(
findUserStatus
(
).
exists
()).
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