diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-11-30 19:25:50 +0100 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-11-30 19:29:19 +0100 |
commit | d03fcbca77368e749cc30c899c38ace1d414a94d (patch) | |
tree | 35ef0c7d92fc8f167eac6362254bd60a74fb8155 /apps/comments | |
parent | 60a73bab1c83c9f8065aa1c642a7ca2c80cd6d2b (diff) | |
download | nextcloud-server-d03fcbca77368e749cc30c899c38ace1d414a94d.tar.gz nextcloud-server-d03fcbca77368e749cc30c899c38ace1d414a94d.zip |
Set text only in the message div of the new comment form
When finding ".message" elements on "view.$el" the message area for the
new comment form and all the comments were matched. Now the selector was
restricted to match only the message area for the new comment form.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/comments')
-rw-r--r-- | apps/comments/tests/js/commentstabviewSpec.js | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/apps/comments/tests/js/commentstabviewSpec.js b/apps/comments/tests/js/commentstabviewSpec.js index 8b99ad081cd..d2170a37f7d 100644 --- a/apps/comments/tests/js/commentstabviewSpec.js +++ b/apps/comments/tests/js/commentstabviewSpec.js @@ -219,6 +219,7 @@ describe('OCA.Comments.CommentsTabView tests', function() { describe('posting comments', function() { var createStub; var currentUserStub; + var $newCommentForm; beforeEach(function() { view.collection.set(testComments); @@ -229,6 +230,8 @@ describe('OCA.Comments.CommentsTabView tests', function() { displayName: 'Test User' }); + $newCommentForm = view.$el.find('.newCommentForm'); + // Required for the absolute selector used to find the new comment // after a successful creation in _onSubmitSuccess. $('#testArea').append(view.$el); @@ -239,8 +242,8 @@ describe('OCA.Comments.CommentsTabView tests', function() { }); it('creates a new comment when clicking post button', function() { - view.$el.find('.message').text('New message'); - view.$el.find('form').submit(); + $newCommentForm.find('.message').text('New message'); + $newCommentForm.submit(); expect(createStub.calledOnce).toEqual(true); expect(createStub.lastCall.args[0]).toEqual({ @@ -253,8 +256,8 @@ describe('OCA.Comments.CommentsTabView tests', function() { }); }); it('creates a new comment with mentions when clicking post button', function() { - view.$el.find('.message').text('New message @anotheruser'); - view.$el.find('form').submit(); + $newCommentForm.find('.message').text('New message @anotheruser'); + $newCommentForm.submit(); var createStubExpectedData = { actorId: 'testuser', @@ -297,8 +300,8 @@ describe('OCA.Comments.CommentsTabView tests', function() { expect($message.find('.avatar[data-user=anotheruser] ~ .contactsmenu-popover').length).toEqual(1); }); it('does not create a comment if the field is empty', function() { - view.$el.find('.message').val(' '); - view.$el.find('form').submit(); + $newCommentForm.find('.message').val(' '); + $newCommentForm.submit(); expect(createStub.notCalled).toEqual(true); }); @@ -307,8 +310,8 @@ describe('OCA.Comments.CommentsTabView tests', function() { for (var i = 0; i < view._commentMaxLength * 2; i++) { bigMessage += 'a'; } - view.$el.find('.message').val(bigMessage); - view.$el.find('form').submit(); + $newCommentForm.find('.message').val(bigMessage); + $newCommentForm.submit(); expect(createStub.notCalled).toEqual(true); }); @@ -319,8 +322,8 @@ describe('OCA.Comments.CommentsTabView tests', function() { beforeEach(function() { tooltipStub = sinon.stub($.fn, 'tooltip'); - $message = view.$el.find('.message'); - $submitButton = view.$el.find('.submit'); + $message = $newCommentForm.find('.message'); + $submitButton = $newCommentForm.find('.submit'); }); afterEach(function() { tooltipStub.restore(); |