|
@@ -10,10 +10,9 @@ describe "FileConverter", ->
|
|
|
|
|
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
|
|
|
|
|
- @child_process =
|
|
|
|
|
- exec : sinon.stub()
|
|
|
|
|
|
|
+ @safe_exec = sinon.stub()
|
|
|
@converter = SandboxedModule.require modulePath, requires:
|
|
@converter = SandboxedModule.require modulePath, requires:
|
|
|
- 'child_process': @child_process
|
|
|
|
|
|
|
+ "./SafeExec": @safe_exec
|
|
|
"logger-sharelatex":
|
|
"logger-sharelatex":
|
|
|
log:->
|
|
log:->
|
|
|
err:->
|
|
err:->
|
|
@@ -25,43 +24,43 @@ describe "FileConverter", ->
|
|
|
describe "convert", ->
|
|
describe "convert", ->
|
|
|
|
|
|
|
|
it "should convert the source to the requested format", (done)->
|
|
it "should convert the source to the requested format", (done)->
|
|
|
- @child_process.exec.callsArgWith(2)
|
|
|
|
|
|
|
+ @safe_exec.callsArgWith(2)
|
|
|
@converter.convert @sourcePath, @format, (err)=>
|
|
@converter.convert @sourcePath, @format, (err)=>
|
|
|
- args = @child_process.exec.args[0][0]
|
|
|
|
|
|
|
+ args = @safe_exec.args[0][0]
|
|
|
args.indexOf(@sourcePath).should.not.equal -1
|
|
args.indexOf(@sourcePath).should.not.equal -1
|
|
|
args.indexOf(@format).should.not.equal -1
|
|
args.indexOf(@format).should.not.equal -1
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
it "should return the dest path", (done)->
|
|
it "should return the dest path", (done)->
|
|
|
- @child_process.exec.callsArgWith(2)
|
|
|
|
|
|
|
+ @safe_exec.callsArgWith(2)
|
|
|
@converter.convert @sourcePath, @format, (err, destPath)=>
|
|
@converter.convert @sourcePath, @format, (err, destPath)=>
|
|
|
destPath.should.equal "#{@sourcePath}.#{@format}"
|
|
destPath.should.equal "#{@sourcePath}.#{@format}"
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
it "should return the error from convert", (done)->
|
|
it "should return the error from convert", (done)->
|
|
|
- @child_process.exec.callsArgWith(2, @error)
|
|
|
|
|
|
|
+ @safe_exec.callsArgWith(2, @error)
|
|
|
@converter.convert @sourcePath, @format, (err)=>
|
|
@converter.convert @sourcePath, @format, (err)=>
|
|
|
err.should.equal @error
|
|
err.should.equal @error
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
it "should not accapt an non aproved format", (done)->
|
|
it "should not accapt an non aproved format", (done)->
|
|
|
- @child_process.exec.callsArgWith(2)
|
|
|
|
|
|
|
+ @safe_exec.callsArgWith(2)
|
|
|
@converter.convert @sourcePath, "ahhhhh", (err)=>
|
|
@converter.convert @sourcePath, "ahhhhh", (err)=>
|
|
|
expect(err).to.exist
|
|
expect(err).to.exist
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
describe "thumbnail", ->
|
|
describe "thumbnail", ->
|
|
|
it "should call converter resize with args", (done)->
|
|
it "should call converter resize with args", (done)->
|
|
|
- @child_process.exec.callsArgWith(2)
|
|
|
|
|
|
|
+ @safe_exec.callsArgWith(2)
|
|
|
@converter.thumbnail @sourcePath, (err)=>
|
|
@converter.thumbnail @sourcePath, (err)=>
|
|
|
- args = @child_process.exec.args[0][0]
|
|
|
|
|
|
|
+ args = @safe_exec.args[0][0]
|
|
|
args.indexOf(@sourcePath).should.not.equal -1
|
|
args.indexOf(@sourcePath).should.not.equal -1
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
describe "preview", ->
|
|
describe "preview", ->
|
|
|
it "should call converter resize with args", (done)->
|
|
it "should call converter resize with args", (done)->
|
|
|
- @child_process.exec.callsArgWith(2)
|
|
|
|
|
|
|
+ @safe_exec.callsArgWith(2)
|
|
|
@converter.preview @sourcePath, (err)=>
|
|
@converter.preview @sourcePath, (err)=>
|
|
|
- args = @child_process.exec.args[0][0]
|
|
|
|
|
|
|
+ args = @safe_exec.args[0][0]
|
|
|
args.indexOf(@sourcePath).should.not.equal -1
|
|
args.indexOf(@sourcePath).should.not.equal -1
|
|
|
done()
|
|
done()
|