diff options
Diffstat (limited to 'apps/comments/tests/js')
-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(); |