aboutsummaryrefslogtreecommitdiffstats
path: root/apps/comments
diff options
context:
space:
mode:
authorAbijeet <abijeetpatro@gmail.com>2018-03-27 01:34:00 +0530
committerAbijeet <abijeetpatro@gmail.com>2018-03-27 01:34:00 +0530
commit16bf9326cb1ccb54351c04193755ade0f49588b4 (patch)
treef286e259821e6c12443cf0c0a3f7b5c95ccc0184 /apps/comments
parent18096f55d07a47c47e02239d82da5bebae617cec (diff)
downloadnextcloud-server-16bf9326cb1ccb54351c04193755ade0f49588b4.tar.gz
nextcloud-server-16bf9326cb1ccb54351c04193755ade0f49588b4.zip
Fixing failing test cases due to change in functionality.
Also fixes scrutinizer warnings. Signed-off-by: Abijeet <abijeetpatro@gmail.com>
Diffstat (limited to 'apps/comments')
-rw-r--r--apps/comments/js/commentsmodifymenu.js8
-rw-r--r--apps/comments/tests/js/commentstabviewSpec.js42
2 files changed, 25 insertions, 25 deletions
diff --git a/apps/comments/js/commentsmodifymenu.js b/apps/comments/js/commentsmodifymenu.js
index 1c5f572d8cc..4b17cbbfbf0 100644
--- a/apps/comments/js/commentsmodifymenu.js
+++ b/apps/comments/js/commentsmodifymenu.js
@@ -7,12 +7,14 @@
* See the COPYING-README file.
*
*/
+
+/* global Handlebars */
(function() {
var TEMPLATE_MENU =
'<ul>' +
'{{#each items}}' +
'<li>' +
- '<a href="#" class="menuitem action action-{{name}} permanent" data-action="{{name}}">' +
+ '<a href="#" class="menuitem action {{name}} permanent" data-action="{{name}}">' +
'{{#if iconClass}}' +
'<span class="icon {{iconClass}}"></span>' +
'{{else}}' +
@@ -64,7 +66,7 @@
}
OC.hideMenus();
-
+
this.trigger('select:menu-item-clicked', event, $target.data('action'));
},
@@ -119,4 +121,4 @@
OCA.Comments = OCA.Comments || {};
OCA.Comments.CommentsModifyMenu = CommentsModifyMenu;
-})(OC, OCA);; \ No newline at end of file
+})(OC, OCA); \ No newline at end of file
diff --git a/apps/comments/tests/js/commentstabviewSpec.js b/apps/comments/tests/js/commentstabviewSpec.js
index 0131bc7bce3..c90ad04e419 100644
--- a/apps/comments/tests/js/commentstabviewSpec.js
+++ b/apps/comments/tests/js/commentstabviewSpec.js
@@ -190,7 +190,7 @@ describe('OCA.Comments.CommentsTabView tests', function() {
expect(fetchStub.notCalled).toEqual(true);
- view.$el.find('.showMore').click();
+ view.$el.find('.showMore').trigger('click');
expect(fetchStub.calledOnce).toEqual(true);
});
@@ -398,10 +398,10 @@ describe('OCA.Comments.CommentsTabView tests', function() {
$message = $newCommentForm.find('.message');
$submitButton = $newCommentForm.find('.submit');
});
- afterEach(function() {
- tooltipStub.restore();
+ afterEach(function() {
+ tooltipStub.restore();
});
-
+
it('does not displays tooltip when limit is far away', function() {
$message.val(createMessageWithLength(3));
$message.trigger('change');
@@ -490,18 +490,21 @@ describe('OCA.Comments.CommentsTabView tests', function() {
it('shows edit link for owner comments', function() {
var $comment = view.$el.find('.comment[data-id=1]');
expect($comment.length).toEqual(1);
+ $comment.find('.action.more').trigger('click');
expect($comment.find('.action.edit').length).toEqual(1);
});
it('does not show edit link for other user\'s comments', function() {
var $comment = view.$el.find('.comment[data-id=2]');
expect($comment.length).toEqual(1);
+ $comment.find('.action.more').trigger('click');
expect($comment.find('.action.edit').length).toEqual(0);
});
it('shows edit form when clicking edit', function() {
var $comment = view.$el.find('.comment[data-id=1]');
- $comment.find('.action.edit').click();
+ $comment.find('.action.more').trigger('click');
+ $comment.find('.action.edit').trigger('click');
expect($comment.hasClass('hidden')).toEqual(true);
var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
@@ -510,7 +513,8 @@ describe('OCA.Comments.CommentsTabView tests', function() {
it('saves message and updates comment item when clicking save', function() {
var $comment = view.$el.find('.comment[data-id=1]');
- $comment.find('.action.edit').click();
+ $comment.find('.action.more').trigger('click');
+ $comment.find('.action.edit').trigger('click');
var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
expect($formRow.length).toEqual(1);
@@ -544,7 +548,8 @@ describe('OCA.Comments.CommentsTabView tests', function() {
it('saves message and updates comment item with mentions when clicking save', function() {
var $comment = view.$el.find('.comment[data-id=3]');
- $comment.find('.action.edit').click();
+ $comment.find('.action.more').trigger('click');
+ $comment.find('.action.edit').trigger('click');
var $formRow = view.$el.find('.newCommentRow.comment[data-id=3]');
expect($formRow.length).toEqual(1);
@@ -591,13 +596,14 @@ describe('OCA.Comments.CommentsTabView tests', function() {
it('restores original comment when cancelling', function() {
var $comment = view.$el.find('.comment[data-id=1]');
- $comment.find('.action.edit').click();
+ $comment.find('.action.more').trigger('click');
+ $comment.find('.action.edit').trigger('click');
var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
expect($formRow.length).toEqual(1);
$formRow.find('textarea').val('modified\nmessage');
- $formRow.find('.cancel').click();
+ $formRow.find('.cancel').trigger('click');
expect(saveStub.notCalled).toEqual(true);
@@ -614,12 +620,8 @@ describe('OCA.Comments.CommentsTabView tests', function() {
it('destroys model when clicking delete', function() {
var destroyStub = sinon.stub(OCA.Comments.CommentModel.prototype, 'destroy');
var $comment = view.$el.find('.comment[data-id=1]');
- $comment.find('.action.edit').click();
-
- var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
- expect($formRow.length).toEqual(1);
-
- $formRow.find('.delete').click();
+ $comment.find('.action.more').trigger('click');
+ $comment.find('.action.delete').trigger('click');
expect(destroyStub.calledOnce).toEqual(true);
expect(destroyStub.thisValues[0].id).toEqual(1);
@@ -630,15 +632,11 @@ describe('OCA.Comments.CommentsTabView tests', function() {
$comment = view.$el.find('.comment[data-id=1]');
expect($comment.length).toEqual(0);
- // form row is gone
- $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
- expect($formRow.length).toEqual(0);
-
destroyStub.restore();
});
it('does not submit comment if the field is empty', function() {
var $comment = view.$el.find('.comment[data-id=1]');
- $comment.find('.action.edit').click();
+ $comment.find('.action.edit').trigger('click');
$comment.find('.message').val(' ');
$comment.find('form').submit();
@@ -646,7 +644,7 @@ describe('OCA.Comments.CommentsTabView tests', function() {
});
it('does not submit comment if the field length is too large', function() {
var $comment = view.$el.find('.comment[data-id=1]');
- $comment.find('.action.edit').click();
+ $comment.find('.action.edit').trigger('click');
$comment.find('.message').val(createMessageWithLength(view._commentMaxLength * 2));
$comment.find('form').submit();
@@ -659,7 +657,7 @@ describe('OCA.Comments.CommentsTabView tests', function() {
beforeEach(function() {
updateMarkerStub = sinon.stub(OCA.Comments.CommentCollection.prototype, 'updateReadMarker');
});
- afterEach(function() {
+ afterEach(function() {
updateMarkerStub.restore();
});