summaryrefslogtreecommitdiffstats
path: root/apps/files/tests/js/fileactionsSpec.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-10-28 20:22:06 +0100
committerVincent Petry <pvince81@owncloud.com>2014-04-02 15:33:47 +0200
commit0be9de5df558232e12e2f582af5d08e1f488ba90 (patch)
treede37dea2e23dd28f631948295979980ec774027f /apps/files/tests/js/fileactionsSpec.js
parent268206cec55921d2d0309469ebd5d9533e4f79ee (diff)
downloadnextcloud-server-0be9de5df558232e12e2f582af5d08e1f488ba90.tar.gz
nextcloud-server-0be9de5df558232e12e2f582af5d08e1f488ba90.zip
Files, trashbin, public apps use ajax/JSON for the file list
Files app: - removed file list template, now rendering list from JSON response - FileList.addFile/addDir is now FileList.add() and takes a JS map with all required arguments instead of having a long number of function arguments - added unit tests for many FileList operations - fixed newfile.php, newfolder.php and rename.php to return the file's full JSON on success - removed obsolete/unused undo code - removed download_url / loading options, now using Files.getDownloadUrl() for that - server side now uses Helper::getFileInfo() to prepare file JSON response - previews are now client-side only Breadcrumbs are now JS only: - Added BreadCrumb class to handle breadcrumb rendering and events - Added unit test for BreadCrumb class - Moved all relevant JS functions to the BreadCrumb class Public page now uses ajax to load the file list: - Added Helper class in sharing app to make it easier to authenticate and retrieve the file's real path - Added ajax/list.php to retrieve the file list - Fixed FileActions and FileList to work with the ajax list Core: - Fixed file picker dialog to use the same list format as files app
Diffstat (limited to 'apps/files/tests/js/fileactionsSpec.js')
-rw-r--r--apps/files/tests/js/fileactionsSpec.js58
1 files changed, 44 insertions, 14 deletions
diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js
index 80c04b5b242..3c22c84b866 100644
--- a/apps/files/tests/js/fileactionsSpec.js
+++ b/apps/files/tests/js/fileactionsSpec.js
@@ -22,6 +22,7 @@
/* global OC, FileActions, FileList */
describe('FileActions tests', function() {
var $filesTable;
+
beforeEach(function() {
// init horrible parameters
var $body = $('body');
@@ -34,17 +35,20 @@ describe('FileActions tests', function() {
$('#dir, #permissions, #filestable').remove();
});
it('calling display() sets file actions', function() {
- // note: download_url is actually the link target, not the actual download URL...
- var $tr = FileList.addFile('testName.txt', 1234, new Date(), false, false, {download_url: 'test/download/url'});
-
- // no actions before call
- expect($tr.find('.action.action-download').length).toEqual(0);
- expect($tr.find('.action.action-rename').length).toEqual(0);
- expect($tr.find('.action.delete').length).toEqual(0);
+ var fileData = {
+ id: 18,
+ type: 'file',
+ name: 'testName.txt',
+ mimetype: 'plain/text',
+ size: '1234',
+ etag: 'a01234c',
+ mtime: '123456'
+ };
- FileActions.display($tr.find('td.filename'), true);
+ // note: FileActions.display() is called implicitly
+ var $tr = FileList.add(fileData);
- // actions defined after cal
+ // actions defined after call
expect($tr.find('.action.action-download').length).toEqual(1);
expect($tr.find('.action.action-download').attr('data-action')).toEqual('Download');
expect($tr.find('.nametext .action.action-rename').length).toEqual(1);
@@ -52,7 +56,16 @@ describe('FileActions tests', function() {
expect($tr.find('.action.delete').length).toEqual(1);
});
it('calling display() twice correctly replaces file actions', function() {
- var $tr = FileList.addFile('testName.txt', 1234, new Date(), false, false, {download_url: 'test/download/url'});
+ var fileData = {
+ id: 18,
+ type: 'file',
+ name: 'testName.txt',
+ mimetype: 'plain/text',
+ size: '1234',
+ etag: 'a01234c',
+ mtime: '123456'
+ };
+ var $tr = FileList.add(fileData);
FileActions.display($tr.find('td.filename'), true);
FileActions.display($tr.find('td.filename'), true);
@@ -64,19 +77,36 @@ describe('FileActions tests', function() {
});
it('redirects to download URL when clicking download', function() {
var redirectStub = sinon.stub(OC, 'redirect');
- // note: download_url is actually the link target, not the actual download URL...
- var $tr = FileList.addFile('test download File.txt', 1234, new Date(), false, false, {download_url: 'test/download/url'});
+ var fileData = {
+ id: 18,
+ type: 'file',
+ name: 'testName.txt',
+ mimetype: 'plain/text',
+ size: '1234',
+ etag: 'a01234c',
+ mtime: '123456'
+ };
+ var $tr = FileList.add(fileData);
FileActions.display($tr.find('td.filename'), true);
$tr.find('.action-download').click();
expect(redirectStub.calledOnce).toEqual(true);
- expect(redirectStub.getCall(0).args[0]).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=test%20download%20File.txt');
+ expect(redirectStub.getCall(0).args[0]).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=testName.txt');
redirectStub.restore();
});
it('deletes file when clicking delete', function() {
var deleteStub = sinon.stub(FileList, 'do_delete');
- var $tr = FileList.addFile('test delete File.txt', 1234, new Date());
+ var fileData = {
+ id: 18,
+ type: 'file',
+ name: 'testName.txt',
+ mimetype: 'plain/text',
+ size: '1234',
+ etag: 'a01234c',
+ mtime: '123456'
+ };
+ var $tr = FileList.add(fileData);
FileActions.display($tr.find('td.filename'), true);
$tr.find('.action.delete').click();