|
@@ -23,6 +23,7 @@ describe "FileHandler", ->
|
|
|
directorySize: sinon.stub()
|
|
directorySize: sinon.stub()
|
|
|
@LocalFileWriter =
|
|
@LocalFileWriter =
|
|
|
writeStream: sinon.stub()
|
|
writeStream: sinon.stub()
|
|
|
|
|
+ getStream: sinon.stub()
|
|
|
deleteFile: sinon.stub()
|
|
deleteFile: sinon.stub()
|
|
|
@FileConverter =
|
|
@FileConverter =
|
|
|
convert: sinon.stub()
|
|
convert: sinon.stub()
|
|
@@ -152,17 +153,20 @@ describe "FileHandler", ->
|
|
|
|
|
|
|
|
it "should _convertFile ", (done)->
|
|
it "should _convertFile ", (done)->
|
|
|
@stubbedStream = {"something":"here"}
|
|
@stubbedStream = {"something":"here"}
|
|
|
|
|
+ @localStream = {
|
|
|
|
|
+ on: ->
|
|
|
|
|
+ }
|
|
|
@PersistorManager.sendFile = sinon.stub().callsArgWith(3)
|
|
@PersistorManager.sendFile = sinon.stub().callsArgWith(3)
|
|
|
- @PersistorManager.getFileStream = sinon.stub().callsArgWith(3, null, @stubbedStream)
|
|
|
|
|
|
|
+ @LocalFileWriter.getStream = sinon.stub().callsArgWith(1, null, @localStream)
|
|
|
@convetedKey = @key+"converted"
|
|
@convetedKey = @key+"converted"
|
|
|
@handler._convertFile = sinon.stub().callsArgWith(3, null, @stubbedPath)
|
|
@handler._convertFile = sinon.stub().callsArgWith(3, null, @stubbedPath)
|
|
|
@ImageOptimiser.compressPng = sinon.stub().callsArgWith(1)
|
|
@ImageOptimiser.compressPng = sinon.stub().callsArgWith(1)
|
|
|
@handler._getConvertedFileAndCache @bucket, @key, @convetedKey, {}, (err, fsStream)=>
|
|
@handler._getConvertedFileAndCache @bucket, @key, @convetedKey, {}, (err, fsStream)=>
|
|
|
@handler._convertFile.called.should.equal true
|
|
@handler._convertFile.called.should.equal true
|
|
|
@PersistorManager.sendFile.calledWith(@bucket, @convetedKey, @stubbedPath).should.equal true
|
|
@PersistorManager.sendFile.calledWith(@bucket, @convetedKey, @stubbedPath).should.equal true
|
|
|
- @PersistorManager.getFileStream.calledWith(@bucket, @convetedKey).should.equal true
|
|
|
|
|
@ImageOptimiser.compressPng.calledWith(@stubbedPath).should.equal true
|
|
@ImageOptimiser.compressPng.calledWith(@stubbedPath).should.equal true
|
|
|
- fsStream.should.equal @stubbedStream
|
|
|
|
|
|
|
+ @LocalFileWriter.getStream.calledWith(@stubbedPath).should.equal true
|
|
|
|
|
+ fsStream.should.equal @localStream
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
describe "_convertFile", ->
|
|
describe "_convertFile", ->
|