diff options
-rw-r--r-- | apps/files/js/fileactions.js | 3 | ||||
-rw-r--r-- | apps/files/tests/js/fileactionsSpec.js | 56 |
2 files changed, 58 insertions, 1 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index bde0b094b87..079c5330ec2 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -144,7 +144,8 @@ order: action.order || 0, icon: action.icon, permissions: action.permissions, - type: action.type || FileActions.TYPE_DROPDOWN + type: action.type || FileActions.TYPE_DROPDOWN, + altText: action.altText || '' }; if (_.isUndefined(action.displayName)) { actionSpec.displayName = t('files', name); diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js index 1254843e66a..6a57c56c3af 100644 --- a/apps/files/tests/js/fileactionsSpec.js +++ b/apps/files/tests/js/fileactionsSpec.js @@ -151,6 +151,62 @@ describe('OCA.Files.FileActions tests', function() { expect($tr.find('.action.action-match').length).toEqual(1); expect($tr.find('.action.action-nomatch').length).toEqual(0); }); + it('display inline icon', function() { + fileActions.registerAction({ + name: 'Icon', + displayName: 'IconDisplay', + type: OCA.Files.FileActions.TYPE_INLINE, + mime: 'all', + icon: OC.imagePath('core', 'actions/icon'), + permissions: OC.PERMISSION_READ + }); + fileActions.registerAction({ + name: 'NoIcon', + displayName: 'NoIconDisplay', + type: OCA.Files.FileActions.TYPE_INLINE, + mime: 'all', + permissions: OC.PERMISSION_READ + }); + + fileActions.display($tr.find('td.filename'), true, fileList); + + expect($tr.find('.action.action-icon').length).toEqual(1); + expect($tr.find('.action.action-icon').find('img').length).toEqual(1); + expect($tr.find('.action.action-icon').find('img').eq(0).attr('src')).toEqual(OC.imagePath('core', 'actions/icon')); + + expect($tr.find('.action.action-noicon').length).toEqual(1); + expect($tr.find('.action.action-noicon').find('img').length).toEqual(0); + }); + it('display alt text on inline icon', function() { + fileActions.registerAction({ + name: 'IconAltText', + displayName: 'IconAltTextDisplay', + type: OCA.Files.FileActions.TYPE_INLINE, + mime: 'all', + icon: OC.imagePath('core', 'actions/iconAltText'), + altText: 'alt icon text', + permissions: OC.PERMISSION_READ + }); + + fileActions.registerAction({ + name: 'IconNoAltText', + displayName: 'IconNoAltTextDisplay', + type: OCA.Files.FileActions.TYPE_INLINE, + mime: 'all', + icon: OC.imagePath('core', 'actions/iconNoAltText'), + permissions: OC.PERMISSION_READ + }); + + fileActions.display($tr.find('td.filename'), true, fileList); + + expect($tr.find('.action.action-iconalttext').length).toEqual(1); + expect($tr.find('.action.action-iconalttext').find('img').length).toEqual(1); + expect($tr.find('.action.action-iconalttext').find('img').eq(0).attr('alt')).toEqual('alt icon text'); + + expect($tr.find('.action.action-iconnoalttext').length).toEqual(1); + expect($tr.find('.action.action-iconnoalttext').find('img').length).toEqual(1); + expect($tr.find('.action.action-iconnoalttext').find('img').eq(0).attr('alt')).toEqual(''); + }); }); describe('action handler', function() { var actionStub, $tr, clock; |