summaryrefslogtreecommitdiffstats
path: root/apps/comments
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-11-30 19:30:27 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-11-30 19:30:27 +0100
commitc43f64d56b517e061ceb48e30ebaa48cc7866236 (patch)
tree2d8cd3b7fe5eb194dfbbec282a5adbad71421ca3 /apps/comments
parentd03fcbca77368e749cc30c899c38ace1d414a94d (diff)
downloadnextcloud-server-c43f64d56b517e061ceb48e30ebaa48cc7866236.tar.gz
nextcloud-server-c43f64d56b517e061ceb48e30ebaa48cc7866236.zip
Add unit tests for posting comments with enter key
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/comments')
-rw-r--r--apps/comments/tests/js/commentstabviewSpec.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/apps/comments/tests/js/commentstabviewSpec.js b/apps/comments/tests/js/commentstabviewSpec.js
index d2170a37f7d..d4456728f02 100644
--- a/apps/comments/tests/js/commentstabviewSpec.js
+++ b/apps/comments/tests/js/commentstabviewSpec.js
@@ -255,6 +255,34 @@ describe('OCA.Comments.CommentsTabView tests', function() {
creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString()
});
});
+ it('creates a new comment when typing enter', function() {
+ $newCommentForm.find('.message').text('New message');
+ var keydownEvent = new $.Event('keydown', {keyCode: 13});
+ $newCommentForm.find('.message').trigger(keydownEvent);
+
+ expect(createStub.calledOnce).toEqual(true);
+ expect(createStub.lastCall.args[0]).toEqual({
+ actorId: 'testuser',
+ actorDisplayName: 'Test User',
+ actorType: 'users',
+ verb: 'comment',
+ message: 'New message',
+ creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString()
+ });
+ expect(keydownEvent.isDefaultPrevented()).toEqual(true);
+ });
+ it('creates a new line when typing shift+enter', function() {
+ $newCommentForm.find('.message').text('New message');
+ var keydownEvent = new $.Event('keydown', {keyCode: 13, shiftKey: true});
+ $newCommentForm.find('.message').trigger(keydownEvent);
+
+ expect(createStub.calledOnce).toEqual(false);
+ // PhantomJS does not seem to handle typing in a contenteditable, so
+ // instead of looking for a new line the best that can be done is
+ // checking that the default behaviour would have been executed.
+ expect($newCommentForm.find('.message').text()).toContain('New message');
+ expect(keydownEvent.isDefaultPrevented()).toEqual(false);
+ });
it('creates a new comment with mentions when clicking post button', function() {
$newCommentForm.find('.message').text('New message @anotheruser');
$newCommentForm.submit();