aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/tests/js
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-09-27 01:50:24 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-10-19 01:46:13 +0200
commita8f1902b02d02cc2b7d624b3d7b288f8aea84fdc (patch)
tree5f5ff64d4b9e989c4573f0e4049c19782282d150 /apps/files/tests/js
parentbea04d12d5a9ae8653277fc6379468d990f397ea (diff)
downloadnextcloud-server-a8f1902b02d02cc2b7d624b3d7b288f8aea84fdc.tar.gz
nextcloud-server-a8f1902b02d02cc2b7d624b3d7b288f8aea84fdc.zip
Add support to FileActionsMenu for icon class functions
Icon class function properties make possible to render a different icon class depending on the context of the file action. Inline file actions had support for them already and called them passing the file name and context of the file action as parameters. Due to this the FileActionsMenu passes those parameters too to icon class functions instead of just the context like done for display name functions. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/files/tests/js')
-rw-r--r--apps/files/tests/js/fileactionsmenuSpec.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/apps/files/tests/js/fileactionsmenuSpec.js b/apps/files/tests/js/fileactionsmenuSpec.js
index 3028db2b3ac..926516b3043 100644
--- a/apps/files/tests/js/fileactionsmenuSpec.js
+++ b/apps/files/tests/js/fileactionsmenuSpec.js
@@ -205,6 +205,34 @@ describe('OCA.Files.FileActionsMenu tests', function() {
expect(displayNameStub.calledWith(menuContext)).toEqual(true);
expect(menu.$el.find('a[data-action=Something]').text()).toEqual('Test');
});
+ it('uses plain iconClass', function() {
+ fileActions.registerAction({
+ name: 'Something',
+ mime: 'text/plain',
+ permissions: OC.PERMISSION_ALL,
+ iconClass: 'test'
+ });
+
+ menu.render();
+
+ expect(menu.$el.find('a[data-action=Something]').children('span.icon').hasClass('test')).toEqual(true);
+ });
+ it('calls iconClass function', function() {
+ var iconClassStub = sinon.stub().returns('test');
+
+ fileActions.registerAction({
+ name: 'Something',
+ mime: 'text/plain',
+ permissions: OC.PERMISSION_ALL,
+ iconClass: iconClassStub
+ });
+
+ menu.render();
+
+ expect(iconClassStub.calledOnce).toEqual(true);
+ expect(iconClassStub.calledWith(menuContext.$file.attr('data-file'), menuContext)).toEqual(true);
+ expect(menu.$el.find('a[data-action=Something]').children('span.icon').hasClass('test')).toEqual(true);
+ });
});
describe('action handler', function() {