From d03fcbca77368e749cc30c899c38ace1d414a94d Mon Sep 17 00:00:00 2001 From: Daniel Calviño Sánchez Date: Thu, 30 Nov 2017 19:25:50 +0100 Subject: Set text only in the message div of the new comment form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- apps/comments/tests/js/commentstabviewSpec.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'apps/comments/tests/js') 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(); -- cgit v1.2.3