mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
fix unit tests for use of fs-extra
This commit is contained in:
parent
7f0e6f3eec
commit
8685b774ee
1 changed files with 11 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue