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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
8e6d2cca
Commit
8e6d2cca
authored
Jan 25, 2019
by
Winnie Hellmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert note_actions_spec.js to Vue test utils
parent
a71d02bb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
19 deletions
+33
-19
spec/javascripts/notes/components/note_actions_spec.js
spec/javascripts/notes/components/note_actions_spec.js
+33
-19
No files found.
spec/javascripts/notes/components/note_actions_spec.js
View file @
8e6d2cca
import
Vue
from
'
vue
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
createStore
from
'
~/notes/stores
'
;
import
noteActions
from
'
~/notes/components/note_actions.vue
'
;
import
{
userDataMock
}
from
'
../mock_data
'
;
describe
(
'
issue_note_actions component
'
,
()
=>
{
let
vm
;
describe
(
'
noteActions
'
,
()
=>
{
let
wrapper
;
let
store
;
let
Component
;
beforeEach
(()
=>
{
Component
=
Vue
.
extend
(
noteActions
);
store
=
createStore
();
});
afterEach
(()
=>
{
vm
.
$
destroy
();
wrapper
.
destroy
();
});
describe
(
'
user is logged in
'
,
()
=>
{
...
...
@@ -36,45 +35,57 @@ describe('issue_note_actions component', () => {
store
.
dispatch
(
'
setUserData
'
,
userDataMock
);
vm
=
new
Component
({
const
localVue
=
createLocalVue
();
wrapper
=
shallowMount
(
noteActions
,
{
store
,
propsData
:
props
,
}).
$mount
();
localVue
,
sync
:
false
,
});
});
it
(
'
should render access level badge
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.note-role
'
).
textContent
.
trim
()).
toEqual
(
props
.
accessLevel
);
expect
(
wrapper
.
find
(
'
.note-role
'
)
.
text
()
.
trim
(),
).
toEqual
(
props
.
accessLevel
);
});
it
(
'
should render emoji link
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-add-award
'
)).
toBeDefined
(
);
expect
(
wrapper
.
find
(
'
.js-add-award
'
).
exists
()).
toBe
(
true
);
});
describe
(
'
actions dropdown
'
,
()
=>
{
it
(
'
should be possible to edit the comment
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-note-edit
'
)).
toBeDefined
(
);
expect
(
wrapper
.
find
(
'
.js-note-edit
'
).
exists
()).
toBe
(
true
);
});
it
(
'
should be possible to report abuse to GitLab
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
`a[href="
${
props
.
reportAbusePath
}
"]`
)).
toBeDefined
(
);
expect
(
wrapper
.
find
(
`a[href="
${
props
.
reportAbusePath
}
"]`
).
exists
()).
toBe
(
true
);
});
it
(
'
should be possible to copy link to a note
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-btn-copy-note-link
'
)).
not
.
toBeNull
(
);
expect
(
wrapper
.
find
(
'
.js-btn-copy-note-link
'
).
exists
()).
toBe
(
true
);
});
it
(
'
should not show copy link action when `noteUrl` prop is empty
'
,
done
=>
{
vm
.
noteUrl
=
''
;
wrapper
.
setProps
({
...
props
,
noteUrl
:
''
,
});
Vue
.
nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-btn-copy-note-link
'
)).
toBeNull
(
);
expect
(
wrapper
.
find
(
'
.js-btn-copy-note-link
'
).
exists
()).
toBe
(
false
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
should be possible to delete comment
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-note-delete
'
)).
toBeDefined
(
);
expect
(
wrapper
.
find
(
'
.js-note-delete
'
).
exists
()).
toBe
(
true
);
});
});
});
...
...
@@ -96,18 +107,21 @@ describe('issue_note_actions component', () => {
reportAbusePath
:
'
/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F7%23note_539&user_id=26
'
,
};
vm
=
new
Component
({
const
localVue
=
createLocalVue
();
wrapper
=
shallowMount
(
noteActions
,
{
store
,
propsData
:
props
,
}).
$mount
();
localVue
,
sync
:
false
,
});
});
it
(
'
should not render emoji link
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-add-award
'
)).
toEqual
(
null
);
expect
(
wrapper
.
find
(
'
.js-add-award
'
).
exists
()).
toBe
(
false
);
});
it
(
'
should not render actions dropdown
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.more-actions
'
)).
toEqual
(
null
);
expect
(
wrapper
.
find
(
'
.more-actions
'
).
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