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
4d7d8dde
Commit
4d7d8dde
authored
Jun 29, 2020
by
jakeburden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make testing DRYer
parent
e40e2d04
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
21 deletions
+16
-21
spec/frontend/notes/components/note_actions_spec.js
spec/frontend/notes/components/note_actions_spec.js
+16
-21
No files found.
spec/frontend/notes/components/note_actions_spec.js
View file @
4d7d8dde
...
@@ -135,11 +135,17 @@ describe('noteActions', () => {
...
@@ -135,11 +135,17 @@ describe('noteActions', () => {
});
});
describe
(
'
when a user has access to edit an issue
'
,
()
=>
{
describe
(
'
when a user has access to edit an issue
'
,
()
=>
{
beforeEach
(
()
=>
{
const
testButtonClickTriggersAction
=
()
=>
{
axiosMock
.
onPut
(
`
${
TEST_HOST
}
/api/v4/projects/group/project/issues/1`
).
reply
(()
=>
{
axiosMock
.
onPut
(
`
${
TEST_HOST
}
/api/v4/projects/group/project/issues/1`
).
reply
(()
=>
{
expect
(
actions
.
updateAssignees
).
toHaveBeenCalled
();
expect
(
actions
.
updateAssignees
).
toHaveBeenCalled
();
});
});
const
assignUserButton
=
wrapper
.
find
(
'
[data-testid="assign-user"]
'
);
expect
(
assignUserButton
.
exists
()).
toBe
(
true
);
assignUserButton
.
trigger
(
'
click
'
);
};
beforeEach
(()
=>
{
store
.
dispatch
(
'
setUserData
'
,
userDataMock
);
store
.
dispatch
(
'
setUserData
'
,
userDataMock
);
store
.
dispatch
(
'
setNoteableData
'
,
{
store
.
dispatch
(
'
setNoteableData
'
,
{
current_user
:
{
current_user
:
{
...
@@ -157,20 +163,16 @@ describe('noteActions', () => {
...
@@ -157,20 +163,16 @@ describe('noteActions', () => {
axiosMock
.
restore
();
axiosMock
.
restore
();
});
});
it
(
'
should be possible to assign the comment author
'
,
()
=>
{
it
(
'
should be possible to assign the comment author
'
,
testButtonClickTriggersAction
);
const
assignUserButton
=
wrapper
.
find
(
'
[data-testid="assign-user"]
'
);
it
(
'
should be possible to unassign the comment author
'
,
testButtonClickTriggersAction
);
expect
(
assignUserButton
.
exists
()).
toBe
(
true
);
assignUserButton
.
trigger
(
'
click
'
);
});
it
(
'
should be possible to unassign the comment author
'
,
()
=>
{
const
assignUserButton
=
wrapper
.
find
(
'
[data-testid="assign-user"]
'
);
expect
(
assignUserButton
.
exists
()).
toBe
(
true
);
assignUserButton
.
trigger
(
'
click
'
);
});
});
});
describe
(
'
when a user does not have access to edit an issue
'
,
()
=>
{
describe
(
'
when a user does not have access to edit an issue
'
,
()
=>
{
const
testButtonDoesNotRender
=
()
=>
{
const
assignUserButton
=
wrapper
.
find
(
'
[data-testid="assign-user"]
'
);
expect
(
assignUserButton
.
exists
()).
toBe
(
false
);
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
wrapper
=
shallowMountNoteActions
(
props
,
{
wrapper
=
shallowMountNoteActions
(
props
,
{
targetType
:
()
=>
'
issue
'
,
targetType
:
()
=>
'
issue
'
,
...
@@ -181,15 +183,8 @@ describe('noteActions', () => {
...
@@ -181,15 +183,8 @@ describe('noteActions', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
it
(
'
should not be possible to assign the comment author
'
,
()
=>
{
it
(
'
should not be possible to assign the comment author
'
,
testButtonDoesNotRender
);
const
assignUserButton
=
wrapper
.
find
(
'
[data-testid="assign-user"]
'
);
it
(
'
should not be possible to unassign the comment author
'
,
testButtonDoesNotRender
);
expect
(
assignUserButton
.
exists
()).
toBe
(
false
);
});
it
(
'
should not be possible to unassign the comment author
'
,
()
=>
{
const
assignUserButton
=
wrapper
.
find
(
'
[data-testid="assign-user"]
'
);
expect
(
assignUserButton
.
exists
()).
toBe
(
false
);
});
});
});
describe
(
'
user is not logged in
'
,
()
=>
{
describe
(
'
user is not logged in
'
,
()
=>
{
...
...
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