Jsunit fixes 1

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-07-17 19:39:01 +02:00 committed by Morris Jobke
parent 43ab2082db
commit 8d3f58c391
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
4 changed files with 12 additions and 6 deletions

View File

@ -118,8 +118,11 @@
*/ */
render: function() { render: function() {
// remove old instances // remove old instances
$('#app-sidebar').remove(); if ($('#app-sidebar').length === 0) {
this.$el.insertAfter($('#app-content')); this.$el.insertAfter($('#app-content'));
} else {
$('#app-sidebar').replaceWith(this.$el)
}
var templateVars = { var templateVars = {
closeLabel: t('files', 'Close') closeLabel: t('files', 'Close')

View File

@ -14,6 +14,7 @@ describe('OCA.Files.FavoritesPlugin tests', function() {
beforeEach(function() { beforeEach(function() {
$('#testArea').append( $('#testArea').append(
'<div id="content">' +
'<div id="app-navigation">' + '<div id="app-navigation">' +
'<ul><li data-id="files"><a>Files</a></li>' + '<ul><li data-id="files"><a>Files</a></li>' +
'<li data-id="sharingin"><a></a></li>' + '<li data-id="sharingin"><a></a></li>' +
@ -25,6 +26,7 @@ describe('OCA.Files.FavoritesPlugin tests', function() {
'<div id="app-content-favorites" class="hidden">' + '<div id="app-content-favorites" class="hidden">' +
'</div>' + '</div>' +
'</div>' + '</div>' +
'</div>' +
'</div>' '</div>'
); );
OC.Plugins.attach('OCA.Files.App', Plugin); OC.Plugins.attach('OCA.Files.App', Plugin);

View File

@ -2491,7 +2491,8 @@ describe('OCA.Files.FileList tests', function() {
expect($('#app-sidebar').hasClass('disappear')).toEqual(false); expect($('#app-sidebar').hasClass('disappear')).toEqual(false);
fileList.remove('One.txt'); 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; jQuery.fx.off = false;
}); });
it('returns the currently selected model instance when calling getModelForFile', function() { 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); expect($('#app-sidebar').hasClass('disappear')).toEqual(false);
fileList.changeDirectory('/another'); fileList.changeDirectory('/another');
expect($('#app-sidebar').hasClass('disappear')).toEqual(true); expect($('#app-sidebar').length).toEqual(0);
jQuery.fx.off = false; jQuery.fx.off = false;
}); });
}); });

View File

@ -22,7 +22,7 @@
describe('Apps base tests', function() { describe('Apps base tests', function() {
describe('Sidebar utility functions', function() { describe('Sidebar utility functions', function() {
beforeEach(function() { beforeEach(function() {
$('#testArea').append('<div id="app-content">Content</div><div id="app-sidebar">The sidebar</div>'); $('#testArea').append('<div id="content"><div id="app-content">Content</div><div id="app-sidebar">The sidebar</div></div>');
jQuery.fx.off = true; jQuery.fx.off = true;
}); });
afterEach(function() { afterEach(function() {
@ -41,7 +41,7 @@ describe('Apps base tests', function() {
}); });
it('triggers appresize event when visibility changed', function() { it('triggers appresize event when visibility changed', function() {
var eventStub = sinon.stub(); var eventStub = sinon.stub();
$('#app-content').on('appresized', eventStub); $('#content').on('appresized', eventStub);
OC.Apps.showAppSidebar(); OC.Apps.showAppSidebar();
expect(eventStub.calledOnce).toEqual(true); expect(eventStub.calledOnce).toEqual(true);
OC.Apps.hideAppSidebar(); OC.Apps.hideAppSidebar();