2014-05-21 10:54:34 +00:00
|
|
|
/**
|
|
|
|
* ownCloud
|
|
|
|
*
|
|
|
|
* @author Vincent Petry
|
|
|
|
* @copyright 2014 Vincent Petry <pvince81@owncloud.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
describe('OCA.Sharing.App tests', function() {
|
|
|
|
var App = OCA.Sharing.App;
|
|
|
|
var fileListIn;
|
|
|
|
var fileListOut;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
$('#testArea').append(
|
|
|
|
'<div id="app-navigation">' +
|
|
|
|
'<ul><li data-id="files"><a>Files</a></li>' +
|
|
|
|
'<li data-id="sharingin"><a></a></li>' +
|
|
|
|
'<li data-id="sharingout"><a></a></li>' +
|
|
|
|
'</ul></div>' +
|
|
|
|
'<div id="app-content">' +
|
|
|
|
'<div id="app-content-files" class="hidden">' +
|
|
|
|
'</div>' +
|
|
|
|
'<div id="app-content-sharingin" class="hidden">' +
|
|
|
|
'</div>' +
|
|
|
|
'<div id="app-content-sharingout" class="hidden">' +
|
|
|
|
'</div>' +
|
|
|
|
'</div>' +
|
|
|
|
'</div>'
|
|
|
|
);
|
|
|
|
fileListIn = App.initSharingIn($('#app-content-sharingin'));
|
|
|
|
fileListOut = App.initSharingOut($('#app-content-sharingout'));
|
|
|
|
});
|
|
|
|
afterEach(function() {
|
2014-07-09 10:26:33 +00:00
|
|
|
App.destroy();
|
2014-05-21 10:54:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('initialization', function() {
|
|
|
|
it('inits sharing-in list on show', function() {
|
2014-06-27 16:25:56 +00:00
|
|
|
expect(fileListIn._sharedWithUser).toEqual(true);
|
2014-05-21 10:54:34 +00:00
|
|
|
});
|
|
|
|
it('inits sharing-out list on show', function() {
|
|
|
|
expect(fileListOut._sharedWithUser).toBeFalsy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
describe('file actions', function() {
|
2014-09-16 13:30:56 +00:00
|
|
|
var oldLegacyFileActions;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
oldLegacyFileActions = window.FileActions;
|
|
|
|
window.FileActions = new OCA.Files.FileActions();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
window.FileActions = oldLegacyFileActions;
|
|
|
|
});
|
2014-05-21 10:54:34 +00:00
|
|
|
it('provides default file actions', function() {
|
|
|
|
_.each([fileListIn, fileListOut], function(fileList) {
|
|
|
|
var fileActions = fileList.fileActions;
|
|
|
|
|
|
|
|
expect(fileActions.actions.all).toBeDefined();
|
|
|
|
expect(fileActions.actions.all.Delete).toBeDefined();
|
|
|
|
expect(fileActions.actions.all.Rename).toBeDefined();
|
2014-06-02 16:39:52 +00:00
|
|
|
expect(fileActions.actions.all.Download).toBeDefined();
|
2014-05-21 10:54:34 +00:00
|
|
|
|
|
|
|
expect(fileActions.defaults.dir).toEqual('Open');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('provides custom file actions', function() {
|
|
|
|
var actionStub = sinon.stub();
|
|
|
|
// regular file action
|
|
|
|
OCA.Files.fileActions.register(
|
|
|
|
'all',
|
|
|
|
'RegularTest',
|
|
|
|
OC.PERMISSION_READ,
|
|
|
|
OC.imagePath('core', 'actions/shared'),
|
|
|
|
actionStub
|
|
|
|
);
|
|
|
|
|
|
|
|
App._inFileList = null;
|
|
|
|
fileListIn = App.initSharingIn($('#app-content-sharingin'));
|
|
|
|
|
|
|
|
expect(fileListIn.fileActions.actions.all.RegularTest).toBeDefined();
|
|
|
|
});
|
|
|
|
it('does not provide legacy file actions', function() {
|
|
|
|
var actionStub = sinon.stub();
|
|
|
|
// legacy file action
|
|
|
|
window.FileActions.register(
|
|
|
|
'all',
|
|
|
|
'LegacyTest',
|
|
|
|
OC.PERMISSION_READ,
|
|
|
|
OC.imagePath('core', 'actions/shared'),
|
|
|
|
actionStub
|
|
|
|
);
|
|
|
|
|
|
|
|
App._inFileList = null;
|
|
|
|
fileListIn = App.initSharingIn($('#app-content-sharingin'));
|
|
|
|
|
|
|
|
expect(fileListIn.fileActions.actions.all.LegacyTest).not.toBeDefined();
|
|
|
|
});
|
|
|
|
it('redirects to files app when opening a directory', function() {
|
|
|
|
var oldList = OCA.Files.App.fileList;
|
|
|
|
// dummy new list to make sure it exists
|
|
|
|
OCA.Files.App.fileList = new OCA.Files.FileList($('<table><thead></thead><tbody></tbody></table>'));
|
|
|
|
|
|
|
|
var setActiveViewStub = sinon.stub(OCA.Files.App, 'setActiveView');
|
|
|
|
// create dummy table so we can click the dom
|
|
|
|
var $table = '<table><thead></thead><tbody id="fileList"></tbody></table>';
|
|
|
|
$('#app-content-sharingin').append($table);
|
|
|
|
|
|
|
|
App._inFileList = null;
|
|
|
|
fileListIn = App.initSharingIn($('#app-content-sharingin'));
|
|
|
|
|
|
|
|
fileListIn.setFiles([{
|
|
|
|
name: 'testdir',
|
|
|
|
type: 'dir',
|
|
|
|
path: '/somewhere/inside/subdir',
|
2014-05-26 10:59:44 +00:00
|
|
|
counterParts: ['user2'],
|
2014-06-02 16:52:31 +00:00
|
|
|
shareOwner: 'user2'
|
2014-05-21 10:54:34 +00:00
|
|
|
}]);
|
|
|
|
|
2015-07-17 12:09:00 +00:00
|
|
|
fileListIn.findFileEl('testdir').find('td .nametext').click();
|
2014-05-21 10:54:34 +00:00
|
|
|
|
|
|
|
expect(OCA.Files.App.fileList.getCurrentDirectory()).toEqual('/somewhere/inside/subdir/testdir');
|
|
|
|
|
|
|
|
expect(setActiveViewStub.calledOnce).toEqual(true);
|
|
|
|
expect(setActiveViewStub.calledWith('files')).toEqual(true);
|
|
|
|
|
|
|
|
setActiveViewStub.restore();
|
|
|
|
|
|
|
|
// restore old list
|
|
|
|
OCA.Files.App.fileList = oldList;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|