diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-09-03 12:17:35 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-09-03 12:17:35 +0200 |
commit | 4ba233350746b4287556d96bb9adbae039f93882 (patch) | |
tree | 3488ba4630ced9f07d89d09a655ffdfc4ecd379b /apps/files/tests/js/fileUploadSpec.js | |
parent | d4104ed9f7b0b7dd497e01fe1f8558cbdb3abf00 (diff) | |
download | nextcloud-server-4ba233350746b4287556d96bb9adbae039f93882.tar.gz nextcloud-server-4ba233350746b4287556d96bb9adbae039f93882.zip |
Added unit tests for "new" file menu and small fixes
- added unit tests for NewFileMenu
- use generateUrl for FileList.createFile and FileList.createDirectory
- added unit tests for FileList.createFile and FileList.createDirectory
Diffstat (limited to 'apps/files/tests/js/fileUploadSpec.js')
-rw-r--r-- | apps/files/tests/js/fileUploadSpec.js | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/apps/files/tests/js/fileUploadSpec.js b/apps/files/tests/js/fileUploadSpec.js index 817654c4fa9..cad8468d1c8 100644 --- a/apps/files/tests/js/fileUploadSpec.js +++ b/apps/files/tests/js/fileUploadSpec.js @@ -19,7 +19,6 @@ * */ -/* global OC */ describe('OC.Upload tests', function() { var $dummyUploader; var testFile; @@ -118,54 +117,4 @@ describe('OC.Upload tests', function() { ); }); }); - describe('New file', function() { - var $input; - var currentDirStub; - - beforeEach(function() { - OC.Upload.init(); - $('#new>a').click(); - $('#new li[data-type=file]').click(); - $input = $('#new input[type=text]'); - - currentDirStub = sinon.stub(FileList, 'getCurrentDirectory'); - currentDirStub.returns('testdir'); - }); - afterEach(function() { - currentDirStub.restore(); - }); - it('sets default text in field', function() { - expect($input.length).toEqual(1); - expect($input.val()).toEqual('New text file.txt'); - }); - it('creates file when enter is pressed', function() { - $input.val('somefile.txt'); - $input.trigger(new $.Event('keyup', {keyCode: 13})); - $input.parent('form').submit(); - expect(fakeServer.requests.length).toEqual(2); - - var request = fakeServer.requests[1]; - expect(request.method).toEqual('POST'); - expect(request.url).toEqual(OC.webroot + '/index.php/apps/files/ajax/newfile.php'); - var query = OC.parseQueryString(request.requestBody); - expect(query).toEqual({ - dir: 'testdir', - filename: 'somefile.txt' - }); - }); - it('prevents entering invalid file names', function() { - $input.val('..'); - $input.trigger(new $.Event('keyup', {keyCode: 13})); - $input.parent('form').submit(); - expect(fakeServer.requests.length).toEqual(1); - }); - it('prevents entering file names that already exist', function() { - var inListStub = sinon.stub(FileList, 'inList').returns(true); - $input.val('existing.txt'); - $input.trigger(new $.Event('keyup', {keyCode: 13})); - $input.parent('form').submit(); - expect(fakeServer.requests.length).toEqual(1); - inListStub.restore(); - }); - }); }); |