fix trashbin js tests
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
d890cd6a4c
commit
c5f77de3e2
|
@ -1,31 +1,38 @@
|
||||||
/**
|
/**
|
||||||
* ownCloud
|
* ownCloud
|
||||||
*
|
*
|
||||||
* @author Vincent Petry
|
* @author Vincent Petry
|
||||||
* @copyright 2014 Vincent Petry <pvince81@owncloud.com>
|
* @copyright 2014 Vincent Petry <pvince81@owncloud.com>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 3 of the License, or any later version.
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public
|
* 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/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
describe('OCA.Trashbin.FileList tests', function() {
|
describe('OCA.Trashbin.FileList tests', function () {
|
||||||
var testFiles, alertStub, notificationStub, fileList;
|
var testFiles, alertStub, notificationStub, fileList, client;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
alertStub = sinon.stub(OC.dialogs, 'alert');
|
alertStub = sinon.stub(OC.dialogs, 'alert');
|
||||||
notificationStub = sinon.stub(OC.Notification, 'show');
|
notificationStub = sinon.stub(OC.Notification, 'show');
|
||||||
|
|
||||||
|
client = new OC.Files.Client({
|
||||||
|
host: 'localhost',
|
||||||
|
port: 80,
|
||||||
|
root: '/remote.php/dav/trashbin/user',
|
||||||
|
useHTTPS: OC.getProtocol() === 'https'
|
||||||
|
});
|
||||||
|
|
||||||
// init parameters and test table elements
|
// init parameters and test table elements
|
||||||
$('#testArea').append(
|
$('#testArea').append(
|
||||||
'<div id="app-content-trashbin">' +
|
'<div id="app-content-trashbin">' +
|
||||||
|
@ -59,21 +66,24 @@ describe('OCA.Trashbin.FileList tests', function() {
|
||||||
testFiles = [{
|
testFiles = [{
|
||||||
id: 1,
|
id: 1,
|
||||||
type: 'file',
|
type: 'file',
|
||||||
name: 'One.txt',
|
name: 'One.txt.d11111',
|
||||||
|
displayName: 'One.txt',
|
||||||
mtime: 11111000,
|
mtime: 11111000,
|
||||||
mimetype: 'text/plain',
|
mimetype: 'text/plain',
|
||||||
etag: 'abc'
|
etag: 'abc'
|
||||||
}, {
|
}, {
|
||||||
id: 2,
|
id: 2,
|
||||||
type: 'file',
|
type: 'file',
|
||||||
name: 'Two.jpg',
|
name: 'Two.jpg.d22222',
|
||||||
|
displayName: 'Two.jpg',
|
||||||
mtime: 22222000,
|
mtime: 22222000,
|
||||||
mimetype: 'image/jpeg',
|
mimetype: 'image/jpeg',
|
||||||
etag: 'def',
|
etag: 'def',
|
||||||
}, {
|
}, {
|
||||||
id: 3,
|
id: 3,
|
||||||
type: 'file',
|
type: 'file',
|
||||||
name: 'Three.pdf',
|
name: 'Three.pdf.d33333',
|
||||||
|
displayName: 'Three.pdf',
|
||||||
mtime: 33333000,
|
mtime: 33333000,
|
||||||
mimetype: 'application/pdf',
|
mimetype: 'application/pdf',
|
||||||
etag: '123',
|
etag: '123',
|
||||||
|
@ -81,7 +91,8 @@ describe('OCA.Trashbin.FileList tests', function() {
|
||||||
id: 4,
|
id: 4,
|
||||||
type: 'dir',
|
type: 'dir',
|
||||||
mtime: 99999000,
|
mtime: 99999000,
|
||||||
name: 'somedir',
|
name: 'somedir.d99999',
|
||||||
|
displayName: 'somedir',
|
||||||
mimetype: 'httpd/unix-directory',
|
mimetype: 'httpd/unix-directory',
|
||||||
etag: '456'
|
etag: '456'
|
||||||
}];
|
}];
|
||||||
|
@ -92,20 +103,21 @@ describe('OCA.Trashbin.FileList tests', function() {
|
||||||
$('#app-content-trashbin'), {
|
$('#app-content-trashbin'), {
|
||||||
fileActions: fileActions,
|
fileActions: fileActions,
|
||||||
multiSelectMenu: [{
|
multiSelectMenu: [{
|
||||||
name: 'restore',
|
name: 'restore',
|
||||||
displayName: t('files', 'Restore'),
|
displayName: t('files', 'Restore'),
|
||||||
iconClass: 'icon-history',
|
iconClass: 'icon-history',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'delete',
|
name: 'delete',
|
||||||
displayName: t('files', 'Delete'),
|
displayName: t('files', 'Delete'),
|
||||||
iconClass: 'icon-delete',
|
iconClass: 'icon-delete',
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
client: client
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
afterEach(function() {
|
afterEach(function () {
|
||||||
testFiles = undefined;
|
testFiles = undefined;
|
||||||
fileList.destroy();
|
fileList.destroy();
|
||||||
fileList = undefined;
|
fileList = undefined;
|
||||||
|
@ -114,17 +126,17 @@ describe('OCA.Trashbin.FileList tests', function() {
|
||||||
notificationStub.restore();
|
notificationStub.restore();
|
||||||
alertStub.restore();
|
alertStub.restore();
|
||||||
});
|
});
|
||||||
describe('Initialization', function() {
|
describe('Initialization', function () {
|
||||||
it('Sorts by mtime by default', function() {
|
it('Sorts by mtime by default', function () {
|
||||||
expect(fileList._sort).toEqual('mtime');
|
expect(fileList._sort).toEqual('mtime');
|
||||||
expect(fileList._sortDirection).toEqual('desc');
|
expect(fileList._sortDirection).toEqual('desc');
|
||||||
});
|
});
|
||||||
it('Always returns read and delete permission', function() {
|
it('Always returns read and delete permission', function () {
|
||||||
expect(fileList.getDirectoryPermissions()).toEqual(OC.PERMISSION_READ | OC.PERMISSION_DELETE);
|
expect(fileList.getDirectoryPermissions()).toEqual(OC.PERMISSION_READ | OC.PERMISSION_DELETE);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('Breadcrumbs', function() {
|
describe('Breadcrumbs', function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
var data = {
|
var data = {
|
||||||
status: 'success',
|
status: 'success',
|
||||||
data: {
|
data: {
|
||||||
|
@ -133,13 +145,13 @@ describe('OCA.Trashbin.FileList tests', function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fakeServer.respondWith(/\/index\.php\/apps\/files_trashbin\/ajax\/list.php\?dir=%2Fsubdir/, [
|
fakeServer.respondWith(/\/index\.php\/apps\/files_trashbin\/ajax\/list.php\?dir=%2Fsubdir/, [
|
||||||
200, {
|
200, {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
JSON.stringify(data)
|
JSON.stringify(data)
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
it('links the breadcrumb to the trashbin view', function() {
|
it('links the breadcrumb to the trashbin view', function () {
|
||||||
fileList.changeDirectory('/subdir', false, true);
|
fileList.changeDirectory('/subdir', false, true);
|
||||||
fakeServer.respond();
|
fakeServer.respond();
|
||||||
var $crumbs = fileList.$el.find('#controls .crumb');
|
var $crumbs = fileList.$el.find('#controls .crumb');
|
||||||
|
@ -152,8 +164,8 @@ describe('OCA.Trashbin.FileList tests', function() {
|
||||||
.toEqual(OC.webroot + '/index.php/apps/files?view=trashbin&dir=/subdir');
|
.toEqual(OC.webroot + '/index.php/apps/files?view=trashbin&dir=/subdir');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('Rendering rows', function() {
|
describe('Rendering rows', function () {
|
||||||
it('renders rows with the correct data when in root', function() {
|
it('renders rows with the correct data when in root', function () {
|
||||||
// dir listing is false when in root
|
// dir listing is false when in root
|
||||||
$('#dir').val('/');
|
$('#dir').val('/');
|
||||||
fileList.setFiles(testFiles);
|
fileList.setFiles(testFiles);
|
||||||
|
@ -174,7 +186,7 @@ describe('OCA.Trashbin.FileList tests', function() {
|
||||||
|
|
||||||
expect(fileList.findFileEl('One.txt.d11111')[0]).toEqual($tr[0]);
|
expect(fileList.findFileEl('One.txt.d11111')[0]).toEqual($tr[0]);
|
||||||
});
|
});
|
||||||
it('renders rows with the correct data when in root after calling setFiles with the same data set', function() {
|
it('renders rows with the correct data when in root after calling setFiles with the same data set', function () {
|
||||||
// dir listing is false when in root
|
// dir listing is false when in root
|
||||||
$('#dir').val('/');
|
$('#dir').val('/');
|
||||||
fileList.setFiles(testFiles);
|
fileList.setFiles(testFiles);
|
||||||
|
@ -196,11 +208,14 @@ describe('OCA.Trashbin.FileList tests', function() {
|
||||||
|
|
||||||
expect(fileList.findFileEl('One.txt.d11111')[0]).toEqual($tr[0]);
|
expect(fileList.findFileEl('One.txt.d11111')[0]).toEqual($tr[0]);
|
||||||
});
|
});
|
||||||
it('renders rows with the correct data when in subdirectory', function() {
|
it('renders rows with the correct data when in subdirectory', function () {
|
||||||
// dir listing is true when in a subdir
|
// dir listing is true when in a subdir
|
||||||
$('#dir').val('/subdir');
|
$('#dir').val('/subdir');
|
||||||
|
|
||||||
fileList.setFiles(testFiles);
|
fileList.setFiles(testFiles.map(function (file) {
|
||||||
|
file.name = file.displayName;
|
||||||
|
return file;
|
||||||
|
}));
|
||||||
var $rows = fileList.$el.find('tbody tr');
|
var $rows = fileList.$el.find('tbody tr');
|
||||||
var $tr = $rows.eq(0);
|
var $tr = $rows.eq(0);
|
||||||
expect($rows.length).toEqual(4);
|
expect($rows.length).toEqual(4);
|
||||||
|
@ -218,42 +233,42 @@ describe('OCA.Trashbin.FileList tests', function() {
|
||||||
|
|
||||||
expect(fileList.findFileEl('One.txt')[0]).toEqual($tr[0]);
|
expect(fileList.findFileEl('One.txt')[0]).toEqual($tr[0]);
|
||||||
});
|
});
|
||||||
it('does not render a size column', function() {
|
it('does not render a size column', function () {
|
||||||
expect(fileList.$el.find('tbody tr .filesize').length).toEqual(0);
|
expect(fileList.$el.find('tbody tr .filesize').length).toEqual(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('File actions', function() {
|
describe('File actions', function () {
|
||||||
describe('Deleting single files', function() {
|
describe('Deleting single files', function () {
|
||||||
// TODO: checks ajax call
|
// TODO: checks ajax call
|
||||||
// TODO: checks spinner
|
// TODO: checks spinner
|
||||||
// TODO: remove item after delete
|
// TODO: remove item after delete
|
||||||
// TODO: bring back item if delete failed
|
// TODO: bring back item if delete failed
|
||||||
});
|
});
|
||||||
describe('Restoring single files', function() {
|
describe('Restoring single files', function () {
|
||||||
// TODO: checks ajax call
|
// TODO: checks ajax call
|
||||||
// TODO: checks spinner
|
// TODO: checks spinner
|
||||||
// TODO: remove item after restore
|
// TODO: remove item after restore
|
||||||
// TODO: bring back item if restore failed
|
// TODO: bring back item if restore failed
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('file previews', function() {
|
describe('file previews', function () {
|
||||||
// TODO: check that preview URL is going through files_trashbin
|
// TODO: check that preview URL is going through files_trashbin
|
||||||
});
|
});
|
||||||
describe('loading file list', function() {
|
describe('loading file list', function () {
|
||||||
// TODO: check that ajax URL is going through files_trashbin
|
// TODO: check that ajax URL is going through files_trashbin
|
||||||
});
|
});
|
||||||
describe('breadcrumbs', function() {
|
describe('breadcrumbs', function () {
|
||||||
// TODO: test label + URL
|
// TODO: test label + URL
|
||||||
});
|
});
|
||||||
describe('elementToFile', function() {
|
describe('elementToFile', function () {
|
||||||
var $tr;
|
var $tr;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
fileList.setFiles(testFiles);
|
fileList.setFiles(testFiles);
|
||||||
$tr = fileList.findFileEl('One.txt.d11111');
|
$tr = fileList.findFileEl('One.txt.d11111');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('converts data attributes to file info structure', function() {
|
it('converts data attributes to file info structure', function () {
|
||||||
var fileInfo = fileList.elementToFile($tr);
|
var fileInfo = fileList.elementToFile($tr);
|
||||||
expect(fileInfo.id).toEqual(1);
|
expect(fileInfo.id).toEqual(1);
|
||||||
expect(fileInfo.name).toEqual('One.txt.d11111');
|
expect(fileInfo.name).toEqual('One.txt.d11111');
|
||||||
|
@ -265,8 +280,8 @@ describe('OCA.Trashbin.FileList tests', function() {
|
||||||
expect(fileInfo.type).toEqual('file');
|
expect(fileInfo.type).toEqual('file');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('Global Actions', function() {
|
describe('Global Actions', function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
fileList.setFiles(testFiles);
|
fileList.setFiles(testFiles);
|
||||||
fileList.findFileEl('One.txt.d11111').find('input:checkbox').click();
|
fileList.findFileEl('One.txt.d11111').find('input:checkbox').click();
|
||||||
fileList.findFileEl('Three.pdf.d33333').find('input:checkbox').click();
|
fileList.findFileEl('Three.pdf.d33333').find('input:checkbox').click();
|
||||||
|
@ -274,12 +289,12 @@ describe('OCA.Trashbin.FileList tests', function() {
|
||||||
fileList.$el.find('.actions-selected').click();
|
fileList.$el.find('.actions-selected').click();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function () {
|
||||||
fileList.$el.find('.actions-selected').click();
|
fileList.$el.find('.actions-selected').click();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Delete', function() {
|
describe('Delete', function () {
|
||||||
it('Shows trashbin actions', function() {
|
it('Shows trashbin actions', function () {
|
||||||
// visible because a few files were selected
|
// visible because a few files were selected
|
||||||
expect($('.selectedActions').is(':visible')).toEqual(true);
|
expect($('.selectedActions').is(':visible')).toEqual(true);
|
||||||
expect($('.selectedActions .item-delete').is(':visible')).toEqual(true);
|
expect($('.selectedActions .item-delete').is(':visible')).toEqual(true);
|
||||||
|
@ -301,99 +316,82 @@ describe('OCA.Trashbin.FileList tests', function() {
|
||||||
expect($('.selectedActions .item-delete').is(':visible')).toEqual(false);
|
expect($('.selectedActions .item-delete').is(':visible')).toEqual(false);
|
||||||
expect($('.selectedActions .item-restore').is(':visible')).toEqual(false);
|
expect($('.selectedActions .item-restore').is(':visible')).toEqual(false);
|
||||||
});
|
});
|
||||||
it('Deletes selected files when "Delete" clicked', function() {
|
it('Deletes selected files when "Delete" clicked', function () {
|
||||||
var request;
|
var request;
|
||||||
var $deleteLink = $('.selectedActions .filesSelectMenu .delete');
|
var promise = fileList._onClickDeleteSelected({
|
||||||
$deleteLink.click();
|
preventDefault: function () {
|
||||||
expect($deleteLink.find('.icon-loading-small').length).toEqual(1);
|
}
|
||||||
expect(fakeServer.requests.length).toEqual(1);
|
});
|
||||||
request = fakeServer.requests[0];
|
var files = ["One.txt.d11111", "Three.pdf.d33333", "somedir.d99999"];
|
||||||
expect(request.url).toEqual(OC.webroot + '/index.php/apps/files_trashbin/ajax/delete.php');
|
expect(fakeServer.requests.length).toEqual(files.length);
|
||||||
expect(OC.parseQueryString(request.requestBody))
|
for (var i = 0; i < files.length; i++) {
|
||||||
.toEqual({'dir': '/', files: '["One.txt.d11111","Three.pdf.d33333","somedir.d99999"]'});
|
request = fakeServer.requests[i];
|
||||||
fakeServer.requests[0].respond(
|
expect(request.url).toEqual(OC.webroot + '/remote.php/dav/trashbin/user/trash/' + files[i]);
|
||||||
200,
|
request.respond(200);
|
||||||
{ 'Content-Type': 'application/json' },
|
}
|
||||||
JSON.stringify({
|
return promise.then(function () {
|
||||||
status: 'success',
|
expect(fileList.findFileEl('One.txt.d11111').length).toEqual(0);
|
||||||
data: {
|
expect(fileList.findFileEl('Three.pdf.d33333').length).toEqual(0);
|
||||||
success: [
|
expect(fileList.findFileEl('somedir.d99999').length).toEqual(0);
|
||||||
{filename: 'One.txt.d11111'},
|
expect(fileList.findFileEl('Two.jpg.d22222').length).toEqual(1);
|
||||||
{filename: 'Three.pdf.d33333'},
|
});
|
||||||
{filename: 'somedir.d99999'}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect($deleteLink.find('.icon-loading-small').length).toEqual(0);
|
|
||||||
expect(fileList.findFileEl('One.txt.d11111').length).toEqual(0);
|
|
||||||
expect(fileList.findFileEl('Three.pdf.d33333').length).toEqual(0);
|
|
||||||
expect(fileList.findFileEl('somedir.d99999').length).toEqual(0);
|
|
||||||
expect(fileList.findFileEl('Two.jpg.d22222').length).toEqual(1);
|
|
||||||
});
|
});
|
||||||
it('Deletes all files when all selected when "Delete" clicked', function() {
|
it('Deletes all files when all selected when "Delete" clicked', function () {
|
||||||
var request;
|
var request;
|
||||||
$('.select-all').click();
|
$('.select-all').click();
|
||||||
$('.selectedActions .filesSelectMenu .delete').click();
|
var promise = fileList._onClickDeleteSelected({
|
||||||
|
preventDefault: function () {
|
||||||
|
}
|
||||||
|
});
|
||||||
expect(fakeServer.requests.length).toEqual(1);
|
expect(fakeServer.requests.length).toEqual(1);
|
||||||
request = fakeServer.requests[0];
|
request = fakeServer.requests[0];
|
||||||
expect(request.url).toEqual(OC.webroot + '/index.php/apps/files_trashbin/ajax/delete.php');
|
expect(request.url).toEqual(OC.webroot + '/remote.php/dav/trashbin/user/trash');
|
||||||
expect(OC.parseQueryString(request.requestBody))
|
request.respond(200);
|
||||||
.toEqual({'dir': '/', allfiles: 'true'});
|
return promise.then(function () {
|
||||||
fakeServer.requests[0].respond(
|
expect(fileList.isEmpty).toEqual(true);
|
||||||
200,
|
});
|
||||||
{ 'Content-Type': 'application/json' },
|
|
||||||
JSON.stringify({status: 'success'})
|
|
||||||
);
|
|
||||||
expect(fileList.isEmpty).toEqual(true);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('Restore', function() {
|
describe('Restore', function () {
|
||||||
it('Restores selected files when "Restore" clicked', function() {
|
it('Restores selected files when "Restore" clicked', function () {
|
||||||
var request;
|
var request;
|
||||||
var $restoreLink = $('.selectedActions .filesSelectMenu .restore');
|
var promise = fileList._onClickRestoreSelected({
|
||||||
$restoreLink.click();
|
preventDefault: function () {
|
||||||
expect($restoreLink.find('.icon-loading-small').length).toEqual(1);
|
}
|
||||||
expect(fakeServer.requests.length).toEqual(1);
|
});
|
||||||
request = fakeServer.requests[0];
|
var files = ["One.txt.d11111", "Three.pdf.d33333", "somedir.d99999"];
|
||||||
expect(request.url).toEqual(OC.webroot + '/index.php/apps/files_trashbin/ajax/undelete.php');
|
expect(fakeServer.requests.length).toEqual(files.length);
|
||||||
expect(OC.parseQueryString(request.requestBody))
|
for (var i = 0; i < files.length; i++) {
|
||||||
.toEqual({'dir': '/', files: '["One.txt.d11111","Three.pdf.d33333","somedir.d99999"]'});
|
request = fakeServer.requests[i];
|
||||||
fakeServer.requests[0].respond(
|
expect(request.url).toEqual(OC.webroot + '/remote.php/dav/trashbin/user/trash/' + files[i]);
|
||||||
200,
|
expect(request.requestHeaders.Destination).toEqual(OC.webroot + '/remote.php/dav/trashbin/user/restore/' + files[i]);
|
||||||
{ 'Content-Type': 'application/json' },
|
request.respond(200);
|
||||||
JSON.stringify({
|
}
|
||||||
status: 'success',
|
return promise.then(function() {
|
||||||
data: {
|
expect(fileList.findFileEl('One.txt.d11111').length).toEqual(0);
|
||||||
success: [
|
expect(fileList.findFileEl('Three.pdf.d33333').length).toEqual(0);
|
||||||
{filename: 'One.txt.d11111'},
|
expect(fileList.findFileEl('somedir.d99999').length).toEqual(0);
|
||||||
{filename: 'Three.pdf.d33333'},
|
expect(fileList.findFileEl('Two.jpg.d22222').length).toEqual(1);
|
||||||
{filename: 'somedir.d99999'}
|
});
|
||||||
]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect($restoreLink.find('.icon-loading-small').length).toEqual(0);
|
|
||||||
expect(fileList.findFileEl('One.txt.d11111').length).toEqual(0);
|
|
||||||
expect(fileList.findFileEl('Three.pdf.d33333').length).toEqual(0);
|
|
||||||
expect(fileList.findFileEl('somedir.d99999').length).toEqual(0);
|
|
||||||
expect(fileList.findFileEl('Two.jpg.d22222').length).toEqual(1);
|
|
||||||
});
|
});
|
||||||
it('Restores all files when all selected when "Restore" clicked', function() {
|
it('Restores all files when all selected when "Restore" clicked', function () {
|
||||||
var request;
|
var request;
|
||||||
$('.select-all').click();
|
$('.select-all').click();
|
||||||
$('.selectedActions .filesSelectMenu .restore').click();
|
var promise = fileList._onClickRestoreSelected({
|
||||||
expect(fakeServer.requests.length).toEqual(1);
|
preventDefault: function () {
|
||||||
request = fakeServer.requests[0];
|
}
|
||||||
expect(request.url).toEqual(OC.webroot + '/index.php/apps/files_trashbin/ajax/undelete.php');
|
});
|
||||||
expect(OC.parseQueryString(request.requestBody))
|
var files = ["One.txt.d11111", "Two.jpg.d22222", "Three.pdf.d33333", "somedir.d99999"];
|
||||||
.toEqual({'dir': '/', allfiles: 'true'});
|
expect(fakeServer.requests.length).toEqual(files.length);
|
||||||
fakeServer.requests[0].respond(
|
for (var i = 0; i < files.length; i++) {
|
||||||
200,
|
request = fakeServer.requests[i];
|
||||||
{ 'Content-Type': 'application/json' },
|
expect(request.url).toEqual(OC.webroot + '/remote.php/dav/trashbin/user/trash/' + files[i]);
|
||||||
JSON.stringify({status: 'success'})
|
expect(request.requestHeaders.Destination).toEqual(OC.webroot + '/remote.php/dav/trashbin/user/restore/' + files[i]);
|
||||||
);
|
request.respond(200);
|
||||||
expect(fileList.isEmpty).toEqual(true);
|
}
|
||||||
|
return promise.then(function() {
|
||||||
|
expect(fileList.isEmpty).toEqual(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue