From baa5a69c55848aede39e14c936f837f77a221496 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 11 Dec 2015 15:14:30 +0100 Subject: Bring back file delete action text to be based on context For received shares, the delete action becomes "Unshare" and for personal mounts it becomes "Disconnect storage". This also makes it possible from now on to pass a function to a file action's "displayName" attribute. --- apps/files/tests/js/fileactionsmenuSpec.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'apps/files/tests') diff --git a/apps/files/tests/js/fileactionsmenuSpec.js b/apps/files/tests/js/fileactionsmenuSpec.js index 747a746a602..3028db2b3ac 100644 --- a/apps/files/tests/js/fileactionsmenuSpec.js +++ b/apps/files/tests/js/fileactionsmenuSpec.js @@ -20,7 +20,7 @@ */ describe('OCA.Files.FileActionsMenu tests', function() { - var fileList, fileActions, menu, actionStub, $tr; + var fileList, fileActions, menu, actionStub, menuContext, $tr; beforeEach(function() { // init horrible parameters @@ -80,7 +80,7 @@ describe('OCA.Files.FileActionsMenu tests', function() { }; $tr = fileList.add(fileData); - var menuContext = { + menuContext = { $file: $tr, fileList: fileList, fileActions: fileActions, @@ -189,6 +189,22 @@ describe('OCA.Files.FileActionsMenu tests', function() { var yactionIndex = menu.$el.find('a[data-action=Yaction]').closest('li').index(); expect(wactionIndex).toBeLessThan(yactionIndex); }); + it('calls displayName function', function() { + var displayNameStub = sinon.stub().returns('Test'); + + fileActions.registerAction({ + name: 'Something', + displayName: displayNameStub, + mime: 'text/plain', + permissions: OC.PERMISSION_ALL + }); + + menu.render(); + + expect(displayNameStub.calledOnce).toEqual(true); + expect(displayNameStub.calledWith(menuContext)).toEqual(true); + expect(menu.$el.find('a[data-action=Something]').text()).toEqual('Test'); + }); }); describe('action handler', function() { -- cgit v1.2.3