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
cba95d9e
Commit
cba95d9e
authored
Oct 03, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for handle save method of the comment form.
parent
4d0dea7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
spec/javascripts/notes/components/issue_comment_form_spec.js
spec/javascripts/notes/components/issue_comment_form_spec.js
+40
-0
No files found.
spec/javascripts/notes/components/issue_comment_form_spec.js
View file @
cba95d9e
...
...
@@ -33,6 +33,30 @@ describe('issue_comment_form component', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.timeline-icon .user-avatar-link
'
).
getAttribute
(
'
href
'
)).
toEqual
(
userDataMock
.
path
);
});
describe
(
'
handleSave
'
,
()
=>
{
it
(
'
should request to save note when note is entered
'
,
()
=>
{
vm
.
note
=
'
hello world
'
;
spyOn
(
vm
,
'
saveNote
'
).
and
.
returnValue
(
new
Promise
(()
=>
{}));
spyOn
(
vm
,
'
resizeTextarea
'
);
spyOn
(
vm
,
'
stopPolling
'
);
vm
.
handleSave
();
expect
(
vm
.
isSubmitting
).
toEqual
(
true
);
expect
(
vm
.
note
).
toEqual
(
''
);
expect
(
vm
.
saveNote
).
toHaveBeenCalled
();
expect
(
vm
.
stopPolling
).
toHaveBeenCalled
();
expect
(
vm
.
resizeTextarea
).
toHaveBeenCalled
();
});
it
(
'
should toggle issue state when no note
'
,
()
=>
{
spyOn
(
vm
,
'
toggleIssueState
'
);
vm
.
handleSave
();
expect
(
vm
.
toggleIssueState
).
toHaveBeenCalled
();
});
});
describe
(
'
textarea
'
,
()
=>
{
it
(
'
should render textarea with placeholder
'
,
()
=>
{
expect
(
...
...
@@ -40,6 +64,22 @@ describe('issue_comment_form component', () => {
).
toEqual
(
'
Write a comment or drag your files here...
'
);
});
it
(
'
should make textarea disabled while requesting
'
,
(
done
)
=>
{
const
$submitButton
=
$
(
vm
.
$el
.
querySelector
(
'
.js-comment-submit-button
'
));
vm
.
note
=
'
hello world
'
;
spyOn
(
vm
,
'
stopPolling
'
);
spyOn
(
vm
,
'
saveNote
'
).
and
.
returnValue
(
new
Promise
(()
=>
{}));
vm
.
$nextTick
(()
=>
{
// Wait for vm.note change triggered. It should enable $submitButton.
$submitButton
.
trigger
(
'
click
'
);
vm
.
$nextTick
(()
=>
{
// Wait for vm.isSubmitting triggered. It should disable textarea.
expect
(
vm
.
$el
.
querySelector
(
'
.js-main-target-form textarea
'
).
disabled
).
toBeTruthy
();
done
();
});
});
});
it
(
'
should support quick actions
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-main-target-form textarea
'
).
getAttribute
(
'
data-supports-quick-actions
'
),
...
...
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