summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-02-19 20:42:29 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-03-01 20:33:14 +0100
commit61bd3631d94ad1b764fe04a74a8fbc1552e0133b (patch)
tree38b6b442682aee7c7936e76af7b37c6a6c2a66dd /apps/files
parenta2672a2ad8335d41c76b10a5f21d21f3b723ecea (diff)
downloadnextcloud-server-61bd3631d94ad1b764fe04a74a8fbc1552e0133b.tar.gz
nextcloud-server-61bd3631d94ad1b764fe04a74a8fbc1552e0133b.zip
Set the width of the parent element in breadcrumb tests
Setting the width of the parent element of the breadcrumbs and then explicitly calling "_resize" is enough to test the resizing behaviour. This makes possible to remove the "setMaxWidth" method and its related code, which was used only for testing purposes. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/js/breadcrumb.js20
-rw-r--r--apps/files/tests/js/breadcrumbSpec.js21
2 files changed, 14 insertions, 27 deletions
diff --git a/apps/files/js/breadcrumb.js b/apps/files/js/breadcrumb.js
index 20b15e3cb93..fe8e54c3a6c 100644
--- a/apps/files/js/breadcrumb.js
+++ b/apps/files/js/breadcrumb.js
@@ -239,19 +239,6 @@
},
/**
- * Show/hide breadcrumbs to fit the given width
- * Mostly used by tests
- *
- * @param {int} availableWidth available width
- */
- setMaxWidth: function (availableWidth) {
- if (this.availableWidth !== availableWidth) {
- this.availableWidth = availableWidth;
- this._resize();
- }
- },
-
- /**
* Calculate real width based on individual crumbs
* More accurate and works with tests
*
@@ -329,12 +316,7 @@
return;
}
- // Used for testing since this.$el.parent fails
- if (!this.availableWidth) {
- this.usedWidth = this.$el.parent().width() - this.$el.parent().find('.actions.creatable').width();
- } else {
- this.usedWidth = this.availableWidth;
- }
+ this.usedWidth = this.$el.parent().width() - this.$el.parent().find('.actions.creatable').width();
// If container is smaller than content
// AND if there are crumbs left to hide
diff --git a/apps/files/tests/js/breadcrumbSpec.js b/apps/files/tests/js/breadcrumbSpec.js
index 5ec5ad2d6e8..d30d9c48e24 100644
--- a/apps/files/tests/js/breadcrumbSpec.js
+++ b/apps/files/tests/js/breadcrumbSpec.js
@@ -188,7 +188,7 @@ describe('OCA.Files.BreadCrumb tests', function() {
$('#controls').append(bc.$el);
// Shrink to show popovermenu
- bc.setMaxWidth(300);
+ $('#controls').width(300);
// triggers resize implicitly
bc.setDirectory(dummyDir);
@@ -265,10 +265,11 @@ describe('OCA.Files.BreadCrumb tests', function() {
afterEach(function() {
bc = null;
});
- it('Hides breadcrumbs to fit max allowed width', function() {
+ it('Hides breadcrumbs to fit available width', function() {
var $crumbs;
- bc.setMaxWidth(500);
+ $('#controls').width(500);
+ bc._resize();
$crumbs = bc.$el.find('.crumb');
@@ -283,10 +284,11 @@ describe('OCA.Files.BreadCrumb tests', function() {
expect($crumbs.eq(6).hasClass('hidden')).toEqual(true);
expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
});
- it('Hides breadcrumbs to fit max allowed width', function() {
+ it('Hides breadcrumbs to fit available width', function() {
var $crumbs;
- bc.setMaxWidth(700);
+ $('#controls').width(700);
+ bc._resize();
$crumbs = bc.$el.find('.crumb');
@@ -301,11 +303,13 @@ describe('OCA.Files.BreadCrumb tests', function() {
expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
});
- it('Updates the breadcrumbs when reducing max allowed width', function() {
+ it('Updates the breadcrumbs when reducing available width', function() {
var $crumbs;
// enough space
- bc.setMaxWidth(1800);
+ $('#controls').width(1800);
+ bc._resize();
+
$crumbs = bc.$el.find('.crumb');
// Menu is hidden
@@ -315,7 +319,8 @@ describe('OCA.Files.BreadCrumb tests', function() {
bc.setDirectory(dummyDir);
// simulate decrease
- bc.setMaxWidth(950);
+ $('#controls').width(950);
+ bc._resize();
// Menu and home are always visible
expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);