Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Grobelny <[email protected]>
  • Loading branch information
tomasz-grobelny committed Nov 24, 2018
1 parent c83c268 commit 04d326f
Show file tree
Hide file tree
Showing 3 changed files with 286 additions and 180 deletions.
11 changes: 7 additions & 4 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,9 @@
options = options || {};
var fileEl = this.findFileEl(name);
var fileData = _.findWhere(this.files, {name: name});
if (!fileData) {
return;
}
var fileId = fileData.id;
if (this._selectedFiles[fileId]) {
// remove from selection first
Expand Down Expand Up @@ -2227,7 +2230,7 @@
return self.filesClient.move(dir + fileName, targetPath + fileName)
.done(function() {
// if still viewing the same directory
if (OC.joinPaths(self.getCurrentDirectory(), '/') === dir) {
if (OC.joinPaths(self.getCurrentDirectory(), '/') === OC.joinPaths(dir, '/')) {
// recalculate folder size
var oldFile = self.findFileEl(target);
var newFile = self.findFileEl(fileName);
Expand Down Expand Up @@ -2367,7 +2370,7 @@
filesToNotify.push(fileName);

// if still viewing the same directory
if (OC.joinPaths(self.getCurrentDirectory(), '/') === dir) {
if (OC.joinPaths(self.getCurrentDirectory(), '/') === OC.joinPaths(dir, '/')) {
// recalculate folder size
var oldFile = self.findFileEl(target);
var newFile = self.findFileEl(fileName);
Expand Down Expand Up @@ -2869,14 +2872,14 @@
self.showFileBusyState($tr, true);
return self.filesClient.remove(dir + '/' + fileName)
.done(function() {
if (OC.joinPaths(self.getCurrentDirectory(), '/') === dir) {
if (OC.joinPaths(self.getCurrentDirectory(), '/') === OC.joinPaths(dir, '/')) {
self.remove(fileName);
}
})
.fail(function(status) {
if (status === 404) {
// the file already did not exist, remove it from the list
if (OC.joinPaths(self.getCurrentDirectory(), '/') === dir) {
if (OC.joinPaths(self.getCurrentDirectory(), '/') === OC.joinPaths(dir, '/')) {
self.remove(fileName);
}
} else {
Expand Down
5 changes: 4 additions & 1 deletion apps/files/tests/js/fileUploadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('OC.Upload tests', function() {
var testFile;
var uploader;
var failStub;
var progressBarStub;

beforeEach(function() {
testFile = {
Expand All @@ -45,7 +46,8 @@ describe('OC.Upload tests', function() {
'</div>'
);
$dummyUploader = $('#file_upload_start');
uploader = new OC.Uploader($dummyUploader);
progressBarStub = {on: function(){}};
uploader = new OC.Uploader($dummyUploader, {progressBar: progressBarStub});
failStub = sinon.stub();
uploader.on('fail', failStub);
});
Expand Down Expand Up @@ -142,6 +144,7 @@ describe('OC.Upload tests', function() {
conflictDialogStub = sinon.stub(OC.dialogs, 'fileexists');

uploader = new OC.Uploader($dummyUploader, {
progressBar: progressBarStub,
fileList: fileList
});

Expand Down
Loading

0 comments on commit 04d326f

Please sign in to comment.