2014-06-13 12:02:19 +04:00
|
|
|
/**
|
|
|
|
* @copyright 2014 Vincent Petry <pvince81@owncloud.com>
|
2021-03-31 13:15:40 +03:00
|
|
|
*
|
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
|
|
|
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
|
|
* @author Vincent Petry <vincent@nextcloud.com>
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2014-06-13 12:02:19 +04:00
|
|
|
|
2018-10-19 18:35:13 +03:00
|
|
|
describe('OCA.Files_External.App tests', function() {
|
2021-03-17 10:25:31 +03:00
|
|
|
const App = OCA.Files_External.App
|
|
|
|
let fileList
|
2014-06-13 12:02:19 +04:00
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
$('#testArea').append(
|
2021-03-17 10:25:31 +03:00
|
|
|
'<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-extstoragemounts" class="hidden">'
|
|
|
|
+ '</div>'
|
|
|
|
+ '</div>'
|
|
|
|
+ '</div>'
|
|
|
|
)
|
|
|
|
fileList = App.initList($('#app-content-extstoragemounts'))
|
|
|
|
})
|
2014-06-13 12:02:19 +04:00
|
|
|
afterEach(function() {
|
2021-03-17 10:25:31 +03:00
|
|
|
App.fileList = null
|
|
|
|
fileList.destroy()
|
|
|
|
fileList = null
|
|
|
|
})
|
2014-06-13 12:02:19 +04:00
|
|
|
|
|
|
|
describe('initialization', function() {
|
|
|
|
it('inits external mounts list on show', function() {
|
2021-03-17 10:25:31 +03:00
|
|
|
expect(App.fileList).toBeDefined()
|
|
|
|
})
|
|
|
|
})
|
2014-06-13 12:02:19 +04:00
|
|
|
describe('file actions', function() {
|
|
|
|
it('provides default file actions', function() {
|
2021-03-17 10:25:31 +03:00
|
|
|
const fileActions = fileList.fileActions
|
2014-06-13 12:02:19 +04:00
|
|
|
|
2021-03-17 10:25:31 +03:00
|
|
|
expect(fileActions.actions.all).toBeDefined()
|
|
|
|
expect(fileActions.actions.all.Delete).toBeDefined()
|
|
|
|
expect(fileActions.actions.all.Rename).toBeDefined()
|
|
|
|
expect(fileActions.actions.all.Download).toBeDefined()
|
2014-06-13 12:02:19 +04:00
|
|
|
|
2021-03-17 10:25:31 +03:00
|
|
|
expect(fileActions.defaults.dir).toEqual('Open')
|
|
|
|
})
|
2014-06-13 12:02:19 +04:00
|
|
|
it('redirects to files app when opening a directory', function() {
|
2021-03-17 10:25:31 +03:00
|
|
|
const oldList = OCA.Files.App.fileList
|
2014-06-13 12:02:19 +04:00
|
|
|
// dummy new list to make sure it exists
|
2021-03-17 10:25:31 +03:00
|
|
|
OCA.Files.App.fileList = new OCA.Files.FileList($('<table><thead></thead><tbody></tbody></table>'))
|
2014-06-13 12:02:19 +04:00
|
|
|
|
2021-03-17 10:25:31 +03:00
|
|
|
const setActiveViewStub = sinon.stub(OCA.Files.App, 'setActiveView')
|
2014-06-13 12:02:19 +04:00
|
|
|
// create dummy table so we can click the dom
|
2021-03-17 10:25:31 +03:00
|
|
|
const $table = '<table><thead></thead><tbody id="fileList"></tbody></table>'
|
|
|
|
$('#app-content-extstoragemounts').append($table)
|
2014-06-13 12:02:19 +04:00
|
|
|
|
2021-03-17 10:25:31 +03:00
|
|
|
App._inFileList = null
|
|
|
|
fileList = App.initList($('#app-content-extstoragemounts'))
|
2014-06-13 12:02:19 +04:00
|
|
|
|
|
|
|
fileList.setFiles([{
|
|
|
|
name: 'testdir',
|
|
|
|
type: 'dir',
|
|
|
|
path: '/somewhere/inside/subdir',
|
|
|
|
counterParts: ['user2'],
|
2021-03-17 10:25:31 +03:00
|
|
|
shareOwner: 'user2',
|
|
|
|
}])
|
2014-06-13 12:02:19 +04:00
|
|
|
|
2021-03-17 10:25:31 +03:00
|
|
|
fileList.findFileEl('testdir').find('td a.name').click()
|
2014-06-13 12:02:19 +04:00
|
|
|
|
2021-03-17 10:25:31 +03:00
|
|
|
expect(OCA.Files.App.fileList.getCurrentDirectory()).toEqual('/somewhere/inside/subdir/testdir')
|
2014-06-13 12:02:19 +04:00
|
|
|
|
2021-03-17 10:25:31 +03:00
|
|
|
expect(setActiveViewStub.calledOnce).toEqual(true)
|
|
|
|
expect(setActiveViewStub.calledWith('files')).toEqual(true)
|
2014-06-13 12:02:19 +04:00
|
|
|
|
2021-03-17 10:25:31 +03:00
|
|
|
setActiveViewStub.restore()
|
2014-06-13 12:02:19 +04:00
|
|
|
|
|
|
|
// restore old list
|
2021-03-17 10:25:31 +03:00
|
|
|
OCA.Files.App.fileList = oldList
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|