From 984ae8140d986e93a2fcea5951436e95c8e2c603 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 11 Aug 2015 11:35:46 +0200 Subject: Fixed file actions menu to close when reclicking trigger FileActionsMenu is now a backbone view. The trigger and highlight handling is now done in the FileActions.showMenu() method using events. --- apps/files/tests/js/fileactionsSpec.js | 24 ++++++++++++++++++++---- apps/files/tests/js/fileactionsmenuSpec.js | 28 +++++----------------------- 2 files changed, 25 insertions(+), 27 deletions(-) (limited to 'apps/files/tests/js') diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js index 8c43b917fa9..236cff6cafd 100644 --- a/apps/files/tests/js/fileactionsSpec.js +++ b/apps/files/tests/js/fileactionsSpec.js @@ -192,10 +192,26 @@ describe('OCA.Files.FileActions tests', function() { context = actionStub.getCall(0).args[1]; expect(context.dir).toEqual('/somepath'); }); - it('shows actions menu when clicking the menu trigger', function() { - expect($tr.find('.menu').length).toEqual(0); - $tr.find('.action-menu').click(); - expect($tr.find('.menu').length).toEqual(1); + describe('actions menu', function() { + it('shows actions menu inside row when clicking the menu trigger', function() { + expect($tr.find('td.filename .fileActionsMenu').length).toEqual(0); + $tr.find('.action-menu').click(); + expect($tr.find('td.filename .fileActionsMenu').length).toEqual(1); + }); + it('shows highlight on current row', function() { + $tr.find('.action-menu').click(); + expect($tr.hasClass('mouseOver')).toEqual(true); + }); + it('cleans up after hiding', function() { + var clock = sinon.useFakeTimers(); + $tr.find('.action-menu').click(); + expect($tr.find('.fileActionsMenu').length).toEqual(1); + OC.hideMenus(); + // sliding animation + clock.tick(500); + expect($tr.hasClass('mouseOver')).toEqual(false); + expect($tr.find('.fileActionsMenu').length).toEqual(0); + }); }); }); describe('custom rendering', function() { diff --git a/apps/files/tests/js/fileactionsmenuSpec.js b/apps/files/tests/js/fileactionsmenuSpec.js index 43439794975..0cfd12a2d04 100644 --- a/apps/files/tests/js/fileactionsmenuSpec.js +++ b/apps/files/tests/js/fileactionsmenuSpec.js @@ -87,24 +87,17 @@ describe('OCA.Files.FileActionsMenu tests', function() { dir: fileList.getCurrentDirectory() }; menu = new OCA.Files.FileActionsMenu(); - menu.showAt(menuContext); + menu.show(menuContext); }); afterEach(function() { fileActions = null; fileList.destroy(); fileList = undefined; - menu.destroy(); + menu.remove(); $('#dir, #permissions, #filestable').remove(); }); describe('rendering', function() { - it('displays menu in the row container', function() { - expect(menu.$el.closest('td.filename').length).toEqual(1); - expect($tr.find('.fileActionsMenu').length).toEqual(1); - }); - it('highlights the row in the file list', function() { - expect($tr.hasClass('mouseOver')).toEqual(true); - }); it('renders dropdown actions in menu', function() { var $action = menu.$el.find('a[data-action=Testdropdown]'); expect($action.length).toEqual(1); @@ -200,7 +193,7 @@ describe('OCA.Files.FileActionsMenu tests', function() { dir: fileList.getCurrentDirectory() }; menu = new OCA.Files.FileActionsMenu(); - menu.showAt(menuContext); + menu.show(menuContext); menu.$el.find('.action-download').click(); @@ -233,7 +226,7 @@ describe('OCA.Files.FileActionsMenu tests', function() { dir: '/anotherpath/there' }; menu = new OCA.Files.FileActionsMenu(); - menu.showAt(menuContext); + menu.show(menuContext); menu.$el.find('.action-download').click(); @@ -266,7 +259,7 @@ describe('OCA.Files.FileActionsMenu tests', function() { dir: '/somepath/dir' }; menu = new OCA.Files.FileActionsMenu(); - menu.showAt(menuContext); + menu.show(menuContext); menu.$el.find('.action-delete').click(); @@ -276,16 +269,5 @@ describe('OCA.Files.FileActionsMenu tests', function() { deleteStub.restore(); }); }); - describe('hiding', function() { - beforeEach(function() { - menu.$el.trigger(new $.Event('afterHide')); - }); - it('removes highlight on current row', function() { - expect($tr.hasClass('mouseOver')).toEqual(false); - }); - it('destroys its DOM element on hide', function() { - expect($tr.find('.fileActionsMenu').length).toEqual(0); - }); - }); }); -- cgit v1.2.3