summaryrefslogtreecommitdiffstats
path: root/apps/files/tests
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2017-11-11 17:27:56 +0100
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2017-11-12 05:20:06 +0100
commitb4f5b38713b140cac2318eaefb945e6126ee81ee (patch)
treef3d32626f08e6cec42b4a5e2a0446bcf31fd78d7 /apps/files/tests
parentf40e56f0e645cfb36ed39decdba7d4a215ed986c (diff)
downloadnextcloud-server-b4f5b38713b140cac2318eaefb945e6126ee81ee.tar.gz
nextcloud-server-b4f5b38713b140cac2318eaefb945e6126ee81ee.zip
Add menu tests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/tests')
-rw-r--r--apps/files/tests/js/breadcrumbSpec.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/apps/files/tests/js/breadcrumbSpec.js b/apps/files/tests/js/breadcrumbSpec.js
index f0489e927eb..fe565f4c3cb 100644
--- a/apps/files/tests/js/breadcrumbSpec.js
+++ b/apps/files/tests/js/breadcrumbSpec.js
@@ -168,6 +168,60 @@ describe('OCA.Files.BreadCrumb tests', function() {
droppableStub.restore();
});
});
+
+ describe('Menu tests', function() {
+ var bc, dummyDir, $crumbmenuLink, $popovermenu;
+
+ beforeEach(function() {
+ dummyDir = '/one/two/three/four/five'
+
+ $('div.crumb').each(function(index){
+ $(this).css('width', 50);
+ });
+
+ bc = new BreadCrumb();
+ // append dummy navigation and controls
+ // as they are currently used for measurements
+ $('#testArea').append(
+ '<div id="controls"></div>'
+ );
+ $('#controls').append(bc.$el);
+
+ // Shrink to show popovermenu
+ bc.setMaxWidth(300);
+
+ // triggers resize implicitly
+ bc.setDirectory(dummyDir);
+
+ $crumbmenuLink = bc.$el.find('.crumbmenu > a');
+ $popovermenu = $crumbmenuLink.next('.popovermenu');
+ });
+ afterEach(function() {
+ bc = null;
+ });
+
+ it('Opens and closes the menu on click', function() {
+ // Menu exists
+ expect($popovermenu.length).toEqual(1);
+
+ // Disable jQuery delay
+ jQuery.fx.off = true
+
+ // Click on menu
+ $crumbmenuLink.click();
+ expect($popovermenu.is(':visible')).toEqual(true);
+
+ // Click on home
+ $(document).mouseup();
+ expect($popovermenu.is(':visible')).toEqual(false);
+
+ });
+ it('Shows only items not in the breadcrumb', function() {
+ var hiddenCrumbs = bc.$el.find('.crumb:not(.crumbmenu).hidden');
+ expect($popovermenu.find('li:not(.in-breadcrumb)').length).toEqual(hiddenCrumbs.length);
+ });
+ });
+
describe('Resizing', function() {
var bc, dummyDir, widths;