summaryrefslogtreecommitdiffstats
path: root/apps/files/tests/js/filesSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/tests/js/filesSpec.js')
-rw-r--r--apps/files/tests/js/filesSpec.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/apps/files/tests/js/filesSpec.js b/apps/files/tests/js/filesSpec.js
index 018c8ef0f3c..7f8848619f5 100644
--- a/apps/files/tests/js/filesSpec.js
+++ b/apps/files/tests/js/filesSpec.js
@@ -19,7 +19,7 @@
*
*/
-/* global Files */
+/* global OC, Files */
describe('Files tests', function() {
describe('File name validation', function() {
it('Validates correct file names', function() {
@@ -82,4 +82,30 @@ describe('Files tests', function() {
}
});
});
+ describe('getDownloadUrl', function() {
+ var curDirStub;
+ beforeEach(function() {
+ curDirStub = sinon.stub(FileList, 'getCurrentDirectory');
+ });
+ afterEach(function() {
+ curDirStub.restore();
+ });
+ it('returns the ajax download URL when only filename specified', function() {
+ curDirStub.returns('/subdir');
+ var url = Files.getDownloadUrl('test file.txt');
+ expect(url).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=test%20file.txt');
+ });
+ it('returns the ajax download URL when filename and dir specified', function() {
+ var url = Files.getDownloadUrl('test file.txt', '/subdir');
+ expect(url).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=test%20file.txt');
+ });
+ it('returns the ajax download URL when filename and root dir specific', function() {
+ var url = Files.getDownloadUrl('test file.txt', '/');
+ expect(url).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2F&files=test%20file.txt');
+ });
+ it('returns the ajax download URL when multiple files specified', function() {
+ var url = Files.getDownloadUrl(['test file.txt', 'abc.txt'], '/subdir');
+ expect(url).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=%5B%22test%20file.txt%22%2C%22abc.txt%22%5D');
+ });
+ });
});