Fix image drag and drop not working anymore (#432)

There has been changes in the model regarding with how the image
information was stored, and the dropzone directive was never modified to
comply with those changes.

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
Juan Cruz Viotti 2016-05-24 11:52:50 -04:00
parent 3b30748b1f
commit 2948d13075
2 changed files with 22 additions and 2 deletions

View File

@ -17,6 +17,7 @@
'use strict';
const _ = require('lodash');
const fs = require('fs');
/**
* @summary Dropzone directive
@ -59,7 +60,10 @@ module.exports = function($timeout) {
// Pass the filename as a named
// parameter called `$file`
$file: filename
$file: {
path: filename,
size: fs.statSync(filename).size
}
});
});

View File

@ -17,6 +17,7 @@
'use strict';
const m = require('mochainon');
const fs = require('fs');
const angular = require('angular');
require('angular-mocks');
@ -40,10 +41,19 @@ describe('Browser: OSDropzone', function() {
it('should pass the file back to the callback as $file', function(done) {
$rootScope.onDropZone = function(file) {
m.chai.expect(file).to.equal('/foo/bar');
statStub.restore();
m.chai.expect(file).to.deep.equal({
path: '/foo/bar',
size: 999999999
});
done();
};
const statStub = m.sinon.stub(fs, 'statSync');
statStub.returns({
size: 999999999
});
const element = $compile('<div os-dropzone="onDropZone($file)">Drop a file here</div>')($rootScope);
$rootScope.$digest();
@ -64,10 +74,16 @@ describe('Browser: OSDropzone', function() {
it('should pass undefined to the callback if not passing $file', function(done) {
$rootScope.onDropZone = function(file) {
statStub.restore();
m.chai.expect(file).to.be.undefined;
done();
};
const statStub = m.sinon.stub(fs, 'statSync');
statStub.returns({
size: 999999999
});
const element = $compile('<div os-dropzone="onDropZone()">Drop a file here</div>')($rootScope);
$rootScope.$digest();