From 80cf4e84e32f09838e9f9e362568f02642ef7658 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 30 Oct 2015 14:37:19 +0100 Subject: Fix file action download spinner --- apps/files/tests/js/fileactionsSpec.js | 43 +++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'apps/files/tests/js/fileactionsSpec.js') diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js index 6a57c56c3af..d29164c5136 100644 --- a/apps/files/tests/js/fileactionsSpec.js +++ b/apps/files/tests/js/fileactionsSpec.js @@ -227,7 +227,7 @@ describe('OCA.Files.FileActions tests', function() { name: 'Test', type: OCA.Files.FileActions.TYPE_INLINE, mime: 'all', - icon: OC.imagePath('core', 'actions/test'), + icon: OC.imagePath('core', 'actions/test'), permissions: OC.PERMISSION_READ, actionHandler: actionStub }); @@ -556,4 +556,45 @@ describe('OCA.Files.FileActions tests', function() { expect(handler.notCalled).toEqual(true); }); }); + describe('default actions', function() { + describe('download', function() { + it('redirects to URL and sets busy state to list', function() { + var handleDownloadStub = sinon.stub(OCA.Files.Files, 'handleDownload'); + var busyStub = sinon.stub(fileList, 'showFileBusyState'); + var fileData = { + id: 18, + type: 'file', + name: 'testName.txt', + mimetype: 'text/plain', + size: '1234', + etag: 'a01234c', + mtime: '123456', + permissions: OC.PERMISSION_READ | OC.PERMISSION_UPDATE + }; + + // note: FileActions.display() is called implicitly + fileList.add(fileData); + + var model = fileList.getModelForFile('testName.txt'); + + fileActions.registerDefaultActions(); + fileActions.triggerAction('Download', model, fileList); + + expect(busyStub.calledOnce).toEqual(true); + expect(busyStub.calledWith('testName.txt', true)).toEqual(true); + expect(handleDownloadStub.calledOnce).toEqual(true); + expect(handleDownloadStub.getCall(0).args[0]).toEqual( + OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=testName.txt' + ); + busyStub.reset(); + handleDownloadStub.yield(); + + expect(busyStub.calledOnce).toEqual(true); + expect(busyStub.calledWith('testName.txt', false)).toEqual(true); + + busyStub.restore(); + handleDownloadStub.restore(); + }); + }); + }); }); -- cgit v1.2.3