From eaa99c7274fdd9fa6beb467ddaf921eaa0465594 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 25 Sep 2017 15:28:31 +0100 Subject: [PATCH] fix unit tests for use of fs-extra --- test/unit/coffee/CompileManagerTests.coffee | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/unit/coffee/CompileManagerTests.coffee b/test/unit/coffee/CompileManagerTests.coffee index b07a02c..591939d 100644 --- a/test/unit/coffee/CompileManagerTests.coffee +++ b/test/unit/coffee/CompileManagerTests.coffee @@ -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