summaryrefslogtreecommitdiffstats
path: root/apps/files/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2014-06-23 22:48:46 +0200
committerLukas Reschke <lukas@statuscode.ch>2014-06-23 22:48:46 +0200
commite070e292bfddc89ddcda251a5f6141e855ef284a (patch)
treeaa99de584e810332c15c88da1b43e70967ea555b /apps/files/tests
parent167ba14af76dcf88340cbe56c513be367cfc13f4 (diff)
parent7d4747ea1692f42b9ae007cf5da654a95c610ec3 (diff)
downloadnextcloud-server-e070e292bfddc89ddcda251a5f6141e855ef284a.tar.gz
nextcloud-server-e070e292bfddc89ddcda251a5f6141e855ef284a.zip
Merge pull request #9170 from owncloud/files-renamevalidationblur
Fix blurring of invalid file name on rename
Diffstat (limited to 'apps/files/tests')
-rw-r--r--apps/files/tests/js/filelistSpec.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 5b72a1355cf..dea7c48e05e 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -597,6 +597,47 @@ describe('OCA.Files.FileList tests', function() {
expect(fileList.$fileList.find('input.filename').length).toEqual(0);
expect(fileList.$fileList.find('form').length).toEqual(0);
});
+ it('Validates the file name', function() {
+ var $input, $tr;
+
+ for (var i = 0; i < testFiles.length; i++) {
+ fileList.add(testFiles[i], {silent: true});
+ }
+
+ // trigger rename prompt
+ fileList.rename('One.txt');
+ $input = fileList.$fileList.find('input.filename');
+ $input.val('Two.jpg');
+
+ // simulate key to trigger validation
+ $input.trigger(new $.Event('keyup', {keyCode: 97}));
+
+ // input is still there with error
+ expect(fileList.$fileList.find('input.filename').length).toEqual(1);
+ expect(fileList.$fileList.find('input.filename').hasClass('error')).toEqual(true);
+
+ // trigger submit does not send server request
+ $input.closest('form').trigger('submit');
+ expect(fakeServer.requests.length).toEqual(0);
+
+ // simulate escape key
+ $input.trigger(new $.Event('keyup', {keyCode: 27}));
+
+ // element is added back with the correct name
+ $tr = fileList.findFileEl('One.txt');
+ expect($tr.length).toEqual(1);
+ expect($tr.find('a .nametext').text().trim()).toEqual('One.txt');
+ expect($tr.find('a.name').is(':visible')).toEqual(true);
+
+ $tr = fileList.findFileEl('Two.jpg');
+ expect($tr.length).toEqual(1);
+ expect($tr.find('a .nametext').text().trim()).toEqual('Two.jpg');
+ expect($tr.find('a.name').is(':visible')).toEqual(true);
+
+ // input and form are gone
+ expect(fileList.$fileList.find('input.filename').length).toEqual(0);
+ expect(fileList.$fileList.find('form').length).toEqual(0);
+ });
});
describe('Moving files', function() {
beforeEach(function() {