diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2015-10-03 15:47:20 +0200 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2015-10-03 15:47:20 +0200 |
commit | 6bf6ff9564640190413d255ed28181f3d9880ea3 (patch) | |
tree | 66456f9b3faca9812fb69bf0dc7e3b53866463b9 | |
parent | 99d7352ef9ed42af6f7d76c4d2e983705c2b43f6 (diff) | |
download | nextcloud-server-6bf6ff9564640190413d255ed28181f3d9880ea3.tar.gz nextcloud-server-6bf6ff9564640190413d255ed28181f3d9880ea3.zip |
If an inline files action provides an alt text show it
* Added unit tests for icon display
* Added unit tests for icon alt text display
-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; |