From 2b4b3b1986e58305c08941f77a693a80cc3d5b85 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 1 Nov 2017 11:27:04 +0100 Subject: adjust jsunit tests Signed-off-by: Arthur Schiwon --- apps/comments/js/commentstabview.js | 8 ++++++-- apps/comments/tests/js/commentstabviewSpec.js | 15 ++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'apps/comments') diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 4ffa76112a1..7398a709421 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -177,9 +177,13 @@ _initAutoComplete: function($target) { var s = this; + var limit = 10; + if(!_.isUndefined(OC.appConfig.comments)) { + limit = OC.appConfig.comments.maxAutoCompleteResults; + } $target.atwho({ at: '@', - limit: OC.appConfig.comments.maxAutoCompleteResults, + limit: limit, callbacks: { remoteFilter: s._onAutoComplete, highlighter: function (li) { @@ -347,7 +351,7 @@ return; } - var $form = $('.comment[data-id="' + model.id + '"] form'); + var $form = this.$container.find('.comment[data-id="' + model.id + '"] form'); var $row = $form.closest('.comment'); var $target = $row.data('commentEl'); if(_.isUndefined($target)) { diff --git a/apps/comments/tests/js/commentstabviewSpec.js b/apps/comments/tests/js/commentstabviewSpec.js index 63a27956f9f..8b99ad081cd 100644 --- a/apps/comments/tests/js/commentstabviewSpec.js +++ b/apps/comments/tests/js/commentstabviewSpec.js @@ -157,7 +157,7 @@ describe('OCA.Comments.CommentsTabView tests', function() { expect($comment.find('.avatar[data-user=macbeth] ~ .contactsmenu-popover').length).toEqual(1); expect($comment.find('.avatar[data-user=banquo]').length).toEqual(1); - expect($comment.find('.avatar-name-wrapper:last-child strong').text()).toEqual('Lord Banquo'); + expect($comment.find('.avatar[data-user=banquo] ~ strong').text()).toEqual('Lord Banquo'); expect($comment.find('.avatar[data-user=banquo] ~ .contactsmenu-popover').length).toEqual(1); }); @@ -239,7 +239,7 @@ describe('OCA.Comments.CommentsTabView tests', function() { }); it('creates a new comment when clicking post button', function() { - view.$el.find('.message').val('New message'); + view.$el.find('.message').text('New message'); view.$el.find('form').submit(); expect(createStub.calledOnce).toEqual(true); @@ -253,7 +253,7 @@ describe('OCA.Comments.CommentsTabView tests', function() { }); }); it('creates a new comment with mentions when clicking post button', function() { - view.$el.find('.message').val('New message @anotheruser'); + view.$el.find('.message').text('New message @anotheruser'); view.$el.find('form').submit(); var createStubExpectedData = { @@ -439,7 +439,7 @@ describe('OCA.Comments.CommentsTabView tests', function() { var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]'); expect($formRow.length).toEqual(1); - $formRow.find('textarea').val('modified message'); + $formRow.find('div.message').text('modified message'); $formRow.find('form').submit(); expect(saveStub.calledOnce).toEqual(true); @@ -451,8 +451,9 @@ describe('OCA.Comments.CommentsTabView tests', function() { // simulate the fact that save sets the attribute model.set('message', 'modified\nmessage'); saveStub.yieldTo('success', model); + view.collection.get(model); - expect(fetchStub.calledOnce).toEqual(true); + expect(fetchStub.called).toEqual(true); fetchStub.yieldTo('success', model); // original comment element is visible again @@ -472,7 +473,7 @@ describe('OCA.Comments.CommentsTabView tests', function() { var $formRow = view.$el.find('.newCommentRow.comment[data-id=3]'); expect($formRow.length).toEqual(1); - $formRow.find('textarea').val('modified\nmessage @anotheruser'); + $formRow.find('div.message').text('modified\nmessage @anotheruser'); $formRow.find('form').submit(); expect(saveStub.calledOnce).toEqual(true); @@ -485,7 +486,7 @@ describe('OCA.Comments.CommentsTabView tests', function() { model.set('message', 'modified\nmessage @anotheruser'); saveStub.yieldTo('success', model); - expect(fetchStub.calledOnce).toEqual(true); + expect(fetchStub.called).toEqual(true); // simulate the fact that fetch sets the attribute model.set('mentions', { -- cgit v1.2.3