summaryrefslogtreecommitdiffstats
path: root/apps/files/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-12-08 11:30:21 +0100
committerLukas Reschke <lukas@owncloud.com>2014-12-08 11:30:21 +0100
commitd3188159d2f2aca64bdc2ec3c3eccfbbfb0b5725 (patch)
treef70960539b575768e3de1f4fac020ad1f5e37555 /apps/files/tests
parente6908f8b890414451dfc32af4d76562016d75d0f (diff)
parente689bc745fc94d9760976e40522ddf96eb5c645c (diff)
downloadnextcloud-server-d3188159d2f2aca64bdc2ec3c3eccfbbfb0b5725.tar.gz
nextcloud-server-d3188159d2f2aca64bdc2ec3c3eccfbbfb0b5725.zip
Merge pull request #12394 from owncloud/files-fileactionsimprovements
Improve FileActions JS to allow for custom rendering
Diffstat (limited to 'apps/files/tests')
-rw-r--r--apps/files/tests/js/fileactionsSpec.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js
index f5f18a45a75..828aec9b6b9 100644
--- a/apps/files/tests/js/fileactionsSpec.js
+++ b/apps/files/tests/js/fileactionsSpec.js
@@ -193,6 +193,54 @@ describe('OCA.Files.FileActions tests', function() {
context = actionStub.getCall(0).args[1];
expect(context.dir).toEqual('/somepath');
});
+ describe('custom rendering', function() {
+ var $tr;
+ beforeEach(function() {
+ var fileData = {
+ id: 18,
+ type: 'file',
+ name: 'testName.txt',
+ mimetype: 'text/plain',
+ size: '1234',
+ etag: 'a01234c',
+ mtime: '123456'
+ };
+ $tr = fileList.add(fileData);
+ });
+ it('regular function', function() {
+ var actionStub = sinon.stub();
+ FileActions.registerAction({
+ name: 'Test',
+ displayName: '',
+ mime: 'all',
+ permissions: OC.PERMISSION_READ,
+ render: function(actionSpec, isDefault, context) {
+ expect(actionSpec.name).toEqual('Test');
+ expect(actionSpec.displayName).toEqual('');
+ expect(actionSpec.permissions).toEqual(OC.PERMISSION_READ);
+ expect(actionSpec.mime).toEqual('all');
+ expect(isDefault).toEqual(false);
+
+ expect(context.fileList).toEqual(fileList);
+ expect(context.$file[0]).toEqual($tr[0]);
+
+ var $customEl = $('<a href="#"><span>blabli</span><span>blabla</span></a>');
+ $tr.find('td:first').append($customEl);
+ return $customEl;
+ },
+ actionHandler: actionStub
+ });
+ FileActions.display($tr.find('td.filename'), true, fileList);
+
+ var $actionEl = $tr.find('td:first .action-test');
+ expect($actionEl.length).toEqual(1);
+ expect($actionEl.hasClass('action')).toEqual(true);
+
+ $actionEl.click();
+ expect(actionStub.calledOnce).toEqual(true);
+ expect(actionStub.getCall(0).args[0]).toEqual('testName.txt');
+ });
+ });
describe('merging', function() {
var $tr;
beforeEach(function() {