fix unit tests for use of fs-extra

This commit is contained in:
Brian Gough 2017-09-25 15:28:31 +01:00
parent 7f0e6f3eec
commit 8685b774ee

View file

@ -21,6 +21,7 @@ describe "CompileManager", ->
"./TikzManager": @TikzManager = {}
"./LockManager": @LockManager = {}
"fs": @fs = {}
"fs-extra": @fse = { ensureDir: sinon.stub().callsArg(1) }
@callback = sinon.stub()
describe "doCompileWithLock", ->
@ -30,6 +31,8 @@ describe "CompileManager", ->
project_id: @project_id = "project-id-123"
user_id: @user_id = "1234"
@output_files = ["foo", "bar"]
@Settings.compileDir = "compiles"
@compileDir = "#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}"
@CompileManager.doCompile = sinon.stub().callsArgWith(1, null, @output_files)
@LockManager.runWithLock = (lockFile, runner, callback) ->
runner (err, result...) ->
@ -39,6 +42,10 @@ describe "CompileManager", ->
beforeEach ->
@CompileManager.doCompileWithLock @request, @callback
it "should ensure that the compile directory exists", ->
@fse.ensureDir.calledWith(@compileDir)
.should.equal true
it "should call doCompile with the request", ->
@CompileManager.doCompile
.calledWith(@request)
@ -55,6 +62,10 @@ describe "CompileManager", ->
callback(@error)
@CompileManager.doCompileWithLock @request, @callback
it "should ensure that the compile directory exists", ->
@fse.ensureDir.calledWith(@compileDir)
.should.equal true
it "should not call doCompile with the request", ->
@CompileManager.doCompile
.called.should.equal false