aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-10-16 21:46:31 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2019-10-29 13:20:08 +0100
commita48359ac024b1b0dbfea2dc3deb93607b0dbf329 (patch)
treeba30df4cb8b31b59cc56d6e08bfb8eb8a255ccfd /apps/files
parent480691a56951e85bf32c86e43e2d3e93dad03560 (diff)
downloadnextcloud-server-a48359ac024b1b0dbfea2dc3deb93607b0dbf329.tar.gz
nextcloud-server-a48359ac024b1b0dbfea2dc3deb93607b0dbf329.zip
Adjust unit tests to new OCA.Sidebar
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/tests/js/filelistSpec.js208
1 files changed, 0 insertions, 208 deletions
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 402cfaa1073..f9c1b5f31cd 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -748,36 +748,6 @@ describe('OCA.Files.FileList tests', function() {
expect(notificationStub.calledOnce).toEqual(true);
});
- it('Shows renamed file details if rename ajax call suceeded', function() {
- fileList.showDetailsView('One.txt');
-
- expect($('#app-sidebar').hasClass('disappear')).toEqual(false);
- expect(fileList._detailsView.getFileInfo().get('id')).toEqual(1);
- expect(fileList._detailsView.getFileInfo().get('name')).toEqual('One.txt');
-
- doRename();
-
- deferredRename.resolve(201);
-
- expect($('#app-sidebar').hasClass('disappear')).toEqual(false);
- expect(fileList._detailsView.getFileInfo().get('id')).toEqual(1);
- expect(fileList._detailsView.getFileInfo().get('name')).toEqual('Tu_after_three.txt');
- });
- it('Shows again file details if rename ajax call failed', function() {
- fileList.showDetailsView('One.txt');
-
- expect($('#app-sidebar').hasClass('disappear')).toEqual(false);
- expect(fileList._detailsView.getFileInfo().get('id')).toEqual(1);
- expect(fileList._detailsView.getFileInfo().get('name')).toEqual('One.txt');
-
- doRename();
-
- deferredRename.reject(403);
-
- expect($('#app-sidebar').hasClass('disappear')).toEqual(false);
- expect(fileList._detailsView.getFileInfo().get('id')).toEqual(1);
- expect(fileList._detailsView.getFileInfo().get('name')).toEqual('One.txt');
- });
it('Correctly updates file link after rename', function() {
var $tr;
doRename();
@@ -2460,184 +2430,6 @@ describe('OCA.Files.FileList tests', function() {
});
});
});
- describe('Details sidebar', function() {
- beforeEach(function() {
- fileList.setFiles(testFiles);
- fileList.showDetailsView('Two.jpg');
- });
- describe('registering', function() {
- var addTabStub;
- var addDetailStub;
-
- beforeEach(function() {
- addTabStub = sinon.stub(OCA.Files.DetailsView.prototype, 'addTabView');
- addDetailStub = sinon.stub(OCA.Files.DetailsView.prototype, 'addDetailView');
- getDetailsStub = sinon.stub(OCA.Files.DetailsView.prototype, 'getDetailViews');
- });
- afterEach(function() {
- addTabStub.restore();
- addDetailStub.restore();
- getDetailsStub.restore();
- });
- it('forward the registered views to the underlying DetailsView', function() {
- fileList.destroy();
- fileList = new OCA.Files.FileList($('#app-content-files'), {
- detailsViewEnabled: true
- });
- fileList.registerTabView(new OCA.Files.DetailTabView());
- fileList.registerDetailView(new OCA.Files.DetailFileInfoView());
-
- expect(addTabStub.calledOnce).toEqual(true);
- // twice because the filelist already registers one by default
- expect(addDetailStub.calledTwice).toEqual(true);
- });
- it('forward getting the registered views to the underlying DetailsView', function() {
- fileList.destroy();
- fileList = new OCA.Files.FileList($('#app-content-files'), {
- detailsViewEnabled: true
- });
- var expectedRegisteredDetailsView = [];
- getDetailsStub.returns(expectedRegisteredDetailsView);
-
- var registeredDetailViews = fileList.getRegisteredDetailViews();
-
- expect(getDetailsStub.calledOnce).toEqual(true);
- expect(registeredDetailViews).toEqual(expectedRegisteredDetailsView);
- });
- it('does not error when registering panels when not details view configured', function() {
- fileList.destroy();
- fileList = new OCA.Files.FileList($('#app-content-files'), {
- detailsViewEnabled: false
- });
- fileList.registerTabView(new OCA.Files.DetailTabView());
- fileList.registerDetailView(new OCA.Files.DetailFileInfoView());
-
- expect(addTabStub.notCalled).toEqual(true);
- expect(addDetailStub.notCalled).toEqual(true);
- });
- it('returns null when getting the registered views when not details view configured', function() {
- fileList.destroy();
- fileList = new OCA.Files.FileList($('#app-content-files'), {
- detailsViewEnabled: false
- });
-
- var registeredDetailViews = fileList.getRegisteredDetailViews();
-
- expect(getDetailsStub.notCalled).toEqual(true);
- expect(registeredDetailViews).toBeNull();
- });
- });
- it('triggers file action when clicking on row if no details view configured', function() {
- fileList.destroy();
- fileList = new OCA.Files.FileList($('#app-content-files'), {
- detailsViewEnabled: false
- });
- var updateDetailsViewStub = sinon.stub(fileList, '_updateDetailsView');
- var actionStub = sinon.stub();
- fileList.setFiles(testFiles);
- fileList.fileActions.register(
- 'text/plain',
- 'Test',
- OC.PERMISSION_ALL,
- function() {
- // Specify icon for hitory button
- return OC.imagePath('core','actions/history');
- },
- actionStub
- );
- fileList.fileActions.setDefault('text/plain', 'Test');
- var $tr = fileList.findFileEl('One.txt');
- $tr.find('td.filesize').click();
- expect(actionStub.calledOnce).toEqual(true);
- expect(updateDetailsViewStub.notCalled).toEqual(true);
- updateDetailsViewStub.restore();
- });
- it('highlights current file when clicked and updates sidebar', function() {
- fileList.fileActions.setDefault('text/plain', 'Test');
- var $tr = fileList.findFileEl('One.txt');
- $tr.find('td.filesize').click();
- expect($tr.hasClass('highlighted')).toEqual(true);
-
- expect(fileList._detailsView.getFileInfo().id).toEqual(1);
- });
- it('keeps the last highlighted file when clicking outside', function() {
- var $tr = fileList.findFileEl('One.txt');
- $tr.find('td.filesize').click();
-
- fileList.$el.find('tfoot').click();
-
- expect($tr.hasClass('highlighted')).toEqual(true);
- expect(fileList._detailsView.getFileInfo().id).toEqual(1);
- });
- it('removes last highlighted file when selecting via checkbox', function() {
- var $tr = fileList.findFileEl('One.txt');
-
- // select
- $tr.find('td.filesize').click();
- $tr.find('input:checkbox').click();
- expect($tr.hasClass('highlighted')).toEqual(false);
-
- // deselect
- $tr.find('td.filesize').click();
- $tr.find('input:checkbox').click();
- expect($tr.hasClass('highlighted')).toEqual(false);
-
- expect(fileList._detailsView.getFileInfo()).toEqual(null);
- });
- it('removes last highlighted file when selecting all files via checkbox', function() {
- var $tr = fileList.findFileEl('One.txt');
-
- // select
- $tr.find('td.filesize').click();
- fileList.$el.find('.select-all.checkbox').click();
- expect($tr.hasClass('highlighted')).toEqual(false);
-
- // deselect
- $tr.find('td.filesize').click();
- fileList.$el.find('.select-all.checkbox').click();
- expect($tr.hasClass('highlighted')).toEqual(false);
-
- expect(fileList._detailsView.getFileInfo()).toEqual(null);
- });
- it('closes sidebar whenever the currently highlighted file was removed from the list', function() {
- jQuery.fx.off = true;
- var $tr = fileList.findFileEl('One.txt');
- $tr.find('td.filesize').click();
- expect($tr.hasClass('highlighted')).toEqual(true);
-
- expect(fileList._detailsView.getFileInfo().id).toEqual(1);
-
- expect($('#app-sidebar').hasClass('disappear')).toEqual(false);
- fileList.remove('One.txt');
- // 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() {
- var $tr = fileList.findFileEl('One.txt');
- $tr.find('td.filesize').click();
-
- var model1 = fileList.getModelForFile('One.txt');
- var model2 = fileList.getModelForFile('One.txt');
- model1.set('test', true);
-
- // it's the same model
- expect(model2).toEqual(model1);
-
- var model3 = fileList.getModelForFile($tr);
- expect(model3).toEqual(model1);
- });
- it('closes the sidebar when switching folders', function() {
- jQuery.fx.off = true;
- var $tr = fileList.findFileEl('One.txt');
- $tr.find('td.filesize').click();
-
- expect($('#app-sidebar').hasClass('disappear')).toEqual(false);
- fileList.changeDirectory('/another');
- expect($('#app-sidebar').length).toEqual(0);
- jQuery.fx.off = false;
- });
- });
describe('File actions', function() {
it('Clicking on a file name will trigger default action', function() {
var actionStub = sinon.stub();