From 0e5abe1ff8d72d2b9482953d34650cdbe58bf42a Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 13 Mar 2015 09:31:43 +0000 Subject: [PATCH] update tests to use safe_exec --- .../unit/coffee/FileConverterTests.coffee | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/services/filestore/test/unit/coffee/FileConverterTests.coffee b/services/filestore/test/unit/coffee/FileConverterTests.coffee index a1305684d1..f8a8add22f 100644 --- a/services/filestore/test/unit/coffee/FileConverterTests.coffee +++ b/services/filestore/test/unit/coffee/FileConverterTests.coffee @@ -10,10 +10,9 @@ describe "FileConverter", -> beforeEach -> - @child_process = - exec : sinon.stub() + @safe_exec = sinon.stub() @converter = SandboxedModule.require modulePath, requires: - 'child_process': @child_process + "./SafeExec": @safe_exec "logger-sharelatex": log:-> err:-> @@ -25,43 +24,43 @@ describe "FileConverter", -> describe "convert", -> it "should convert the source to the requested format", (done)-> - @child_process.exec.callsArgWith(2) + @safe_exec.callsArgWith(2) @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(@format).should.not.equal -1 done() it "should return the dest path", (done)-> - @child_process.exec.callsArgWith(2) + @safe_exec.callsArgWith(2) @converter.convert @sourcePath, @format, (err, destPath)=> destPath.should.equal "#{@sourcePath}.#{@format}" 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)=> err.should.equal @error done() it "should not accapt an non aproved format", (done)-> - @child_process.exec.callsArgWith(2) + @safe_exec.callsArgWith(2) @converter.convert @sourcePath, "ahhhhh", (err)=> expect(err).to.exist done() describe "thumbnail", -> it "should call converter resize with args", (done)-> - @child_process.exec.callsArgWith(2) + @safe_exec.callsArgWith(2) @converter.thumbnail @sourcePath, (err)=> - args = @child_process.exec.args[0][0] + args = @safe_exec.args[0][0] args.indexOf(@sourcePath).should.not.equal -1 done() describe "preview", -> it "should call converter resize with args", (done)-> - @child_process.exec.callsArgWith(2) + @safe_exec.callsArgWith(2) @converter.preview @sourcePath, (err)=> - args = @child_process.exec.args[0][0] + args = @safe_exec.args[0][0] args.indexOf(@sourcePath).should.not.equal -1 done()