summaryrefslogtreecommitdiffstats
path: root/apps/files/tests/js/filelistSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/tests/js/filelistSpec.js')
-rw-r--r--apps/files/tests/js/filelistSpec.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 6b28a02989e..c26e65fc4de 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -18,25 +18,32 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
+/* global OC, FileList */
describe('FileList tests', function() {
beforeEach(function() {
// init horrible parameters
- $('<input type="hidden" id="dir" value="/subdir"></input>').append('body');
- $('<input type="hidden" id="permissions" value="31"></input>').append('body');
+ var $body = $('body');
+ $body.append('<input type="hidden" id="dir" value="/subdir"></input>');
+ $body.append('<input type="hidden" id="permissions" value="31"></input>');
+ // dummy files table
+ $body.append('<table id="filestable"></table>');
});
afterEach(function() {
- $('#dir, #permissions').remove();
+ $('#dir, #permissions, #filestable').remove();
});
it('generates file element with correct attributes when calling addFile', function() {
var lastMod = new Date(10000);
+ // note: download_url is actually the link target, not the actual download URL...
var $tr = FileList.addFile('testName.txt', 1234, lastMod, false, false, {download_url: 'test/download/url'});
expect($tr).toBeDefined();
expect($tr[0].tagName.toLowerCase()).toEqual('tr');
+ expect($tr.find('a:first').attr('href')).toEqual('test/download/url');
expect($tr.attr('data-type')).toEqual('file');
expect($tr.attr('data-file')).toEqual('testName.txt');
expect($tr.attr('data-size')).toEqual('1234');
- //expect($tr.attr('data-permissions')).toEqual('31');
+ expect($tr.attr('data-permissions')).toEqual('31');
//expect($tr.attr('data-mime')).toEqual('plain/text');
});
it('generates dir element with correct attributes when calling addDir', function() {
@@ -48,7 +55,11 @@ describe('FileList tests', function() {
expect($tr.attr('data-type')).toEqual('dir');
expect($tr.attr('data-file')).toEqual('testFolder');
expect($tr.attr('data-size')).toEqual('1234');
- //expect($tr.attr('data-permissions')).toEqual('31');
+ expect($tr.attr('data-permissions')).toEqual('31');
//expect($tr.attr('data-mime')).toEqual('httpd/unix-directory');
});
+ it('returns correct download URL', function() {
+ expect(FileList.getDownloadUrl('some file.txt')).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?files=some%20file.txt&dir=%2Fsubdir&download');
+ expect(FileList.getDownloadUrl('some file.txt', '/anotherpath/abc')).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?files=some%20file.txt&dir=%2Fanotherpath%2Fabc&download');
+ });
});