fix unit tests for use of fs-extra
This commit is contained in:
@@ -21,6 +21,7 @@ describe "CompileManager", ->
|
|||||||
"./TikzManager": @TikzManager = {}
|
"./TikzManager": @TikzManager = {}
|
||||||
"./LockManager": @LockManager = {}
|
"./LockManager": @LockManager = {}
|
||||||
"fs": @fs = {}
|
"fs": @fs = {}
|
||||||
|
"fs-extra": @fse = { ensureDir: sinon.stub().callsArg(1) }
|
||||||
@callback = sinon.stub()
|
@callback = sinon.stub()
|
||||||
|
|
||||||
describe "doCompileWithLock", ->
|
describe "doCompileWithLock", ->
|
||||||
@@ -30,6 +31,8 @@ describe "CompileManager", ->
|
|||||||
project_id: @project_id = "project-id-123"
|
project_id: @project_id = "project-id-123"
|
||||||
user_id: @user_id = "1234"
|
user_id: @user_id = "1234"
|
||||||
@output_files = ["foo", "bar"]
|
@output_files = ["foo", "bar"]
|
||||||
|
@Settings.compileDir = "compiles"
|
||||||
|
@compileDir = "#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}"
|
||||||
@CompileManager.doCompile = sinon.stub().callsArgWith(1, null, @output_files)
|
@CompileManager.doCompile = sinon.stub().callsArgWith(1, null, @output_files)
|
||||||
@LockManager.runWithLock = (lockFile, runner, callback) ->
|
@LockManager.runWithLock = (lockFile, runner, callback) ->
|
||||||
runner (err, result...) ->
|
runner (err, result...) ->
|
||||||
@@ -39,6 +42,10 @@ describe "CompileManager", ->
|
|||||||
beforeEach ->
|
beforeEach ->
|
||||||
@CompileManager.doCompileWithLock @request, @callback
|
@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", ->
|
it "should call doCompile with the request", ->
|
||||||
@CompileManager.doCompile
|
@CompileManager.doCompile
|
||||||
.calledWith(@request)
|
.calledWith(@request)
|
||||||
@@ -55,6 +62,10 @@ describe "CompileManager", ->
|
|||||||
callback(@error)
|
callback(@error)
|
||||||
@CompileManager.doCompileWithLock @request, @callback
|
@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", ->
|
it "should not call doCompile with the request", ->
|
||||||
@CompileManager.doCompile
|
@CompileManager.doCompile
|
||||||
.called.should.equal false
|
.called.should.equal false
|
||||||
|
|||||||
Reference in New Issue
Block a user