Skip to content

Commit

Permalink
Fix file move tests
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Nov 7, 2018
1 parent 2ba519a commit c48722c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions apps/files/tests/js/filelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ describe('OCA.Files.FileList tests', function() {
done();
});
});
it('Restores thumbnail if a file could not be moved', function() {
it('Restores thumbnail if a file could not be moved', function(done) {
return fileList.move('One.txt', '/somedir').then(function(){

expect(fileList.findFileEl('One.txt').find('.thumbnail').parent().attr('class'))
Expand All @@ -922,6 +922,7 @@ describe('OCA.Files.FileList tests', function() {

expect(OC.TestUtil.getImageUrl(fileList.findFileEl('One.txt').find('.thumbnail')))
.toEqual(OC.imagePath('core', 'filetypes/text.svg'));
done();
});
});
});
Expand Down Expand Up @@ -1766,7 +1767,12 @@ describe('OCA.Files.FileList tests', function() {
});
it('dropping files on breadcrumb calls move operation', function(done) {
var testDir = '/subdir/two/three with space/four/five';
var moveStub = sinon.stub(filesClient, 'move').returns($.Deferred().promise());
var moveStub = sinon.stub(filesClient, 'move');
var resolve1, resolve2;
var deferredMove1 = $.Deferred();
var deferredMove2 = $.Deferred();
moveStub.onCall(0).returns(deferredMove1.promise());
moveStub.onCall(1).returns(deferredMove2.promise());
fileList.changeDirectory(testDir);
deferredList.resolve(200, [testRoot].concat(testFiles));
var $crumb = fileList.breadcrumb.$el.find('.crumb:eq(4)');
Expand All @@ -1782,8 +1788,7 @@ describe('OCA.Files.FileList tests', function() {
$('<tr data-file="Two.jpg" data-dir="' + testDir + '"></tr>')
]);
// simulate drop event
return fileList._onDropOnBreadCrumb(new $.Event('drop', {target: $crumb}), ui).then(function(){

var result = fileList._onDropOnBreadCrumb(new $.Event('drop', {target: $crumb}), ui).then(function(){
expect(moveStub.callCount).toEqual(2);
expect(moveStub.getCall(0).args[0]).toEqual(testDir + '/One.txt');
expect(moveStub.getCall(0).args[1]).toEqual('/subdir/two/three with space/One.txt');
Expand All @@ -1792,6 +1797,9 @@ describe('OCA.Files.FileList tests', function() {
moveStub.restore();
done();
});
deferredMove1.resolve(201);
deferredMove2.resolve(201);
return result;
});
it('dropping files on same dir breadcrumb does nothing', function() {
var testDir = '/subdir/two/three with space/four/five';
Expand Down

0 comments on commit c48722c

Please sign in to comment.