From 8d3f58c3917018a859917af377b8954910a3ba6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Tue, 17 Jul 2018 19:39:01 +0200 Subject: [PATCH] Jsunit fixes 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files/js/detailsview.js | 7 +++++-- apps/files/tests/js/favoritespluginspec.js | 2 ++ apps/files/tests/js/filelistSpec.js | 5 +++-- core/js/tests/specs/appsSpec.js | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/files/js/detailsview.js b/apps/files/js/detailsview.js index 1d33987cd5..ac10b8380e 100644 --- a/apps/files/js/detailsview.js +++ b/apps/files/js/detailsview.js @@ -118,8 +118,11 @@ */ render: function() { // remove old instances - $('#app-sidebar').remove(); - this.$el.insertAfter($('#app-content')); + if ($('#app-sidebar').length === 0) { + this.$el.insertAfter($('#app-content')); + } else { + $('#app-sidebar').replaceWith(this.$el) + } var templateVars = { closeLabel: t('files', 'Close') diff --git a/apps/files/tests/js/favoritespluginspec.js b/apps/files/tests/js/favoritespluginspec.js index 1b144c2870..bc4ec5b9fc 100644 --- a/apps/files/tests/js/favoritespluginspec.js +++ b/apps/files/tests/js/favoritespluginspec.js @@ -14,6 +14,7 @@ describe('OCA.Files.FavoritesPlugin tests', function() { beforeEach(function() { $('#testArea').append( + '
' + '
' + '
  • Files
  • ' + '
  • ' + @@ -25,6 +26,7 @@ describe('OCA.Files.FavoritesPlugin tests', function() { '' + '
' + + '
' + '' ); OC.Plugins.attach('OCA.Files.App', Plugin); diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index efaf9968de..1261e468af 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -2491,7 +2491,8 @@ describe('OCA.Files.FileList tests', function() { expect($('#app-sidebar').hasClass('disappear')).toEqual(false); fileList.remove('One.txt'); - expect($('#app-sidebar').hasClass('disappear')).toEqual(true); + // sidebar is removed on close before being + expect($('#app-sidebar').length).toEqual(0); jQuery.fx.off = false; }); it('returns the currently selected model instance when calling getModelForFile', function() { @@ -2515,7 +2516,7 @@ describe('OCA.Files.FileList tests', function() { expect($('#app-sidebar').hasClass('disappear')).toEqual(false); fileList.changeDirectory('/another'); - expect($('#app-sidebar').hasClass('disappear')).toEqual(true); + expect($('#app-sidebar').length).toEqual(0); jQuery.fx.off = false; }); }); diff --git a/core/js/tests/specs/appsSpec.js b/core/js/tests/specs/appsSpec.js index c3352e3e4a..3a4c413bbd 100644 --- a/core/js/tests/specs/appsSpec.js +++ b/core/js/tests/specs/appsSpec.js @@ -22,7 +22,7 @@ describe('Apps base tests', function() { describe('Sidebar utility functions', function() { beforeEach(function() { - $('#testArea').append('
Content
The sidebar
'); + $('#testArea').append('
Content
The sidebar
'); jQuery.fx.off = true; }); afterEach(function() { @@ -41,7 +41,7 @@ describe('Apps base tests', function() { }); it('triggers appresize event when visibility changed', function() { var eventStub = sinon.stub(); - $('#app-content').on('appresized', eventStub); + $('#content').on('appresized', eventStub); OC.Apps.showAppSidebar(); expect(eventStub.calledOnce).toEqual(true); OC.Apps.hideAppSidebar();