From fd5b557ddefd093bcb73b8ddaa55c4a75d6ad482 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 18 Jul 2017 11:29:59 +0100 Subject: [PATCH 1/2] fix exception for empty content in TikzManager --- services/clsi/app/coffee/TikzManager.coffee | 4 ++-- services/clsi/test/unit/coffee/TikzManager.coffee | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/services/clsi/app/coffee/TikzManager.coffee b/services/clsi/app/coffee/TikzManager.coffee index cfa13321a6..5c08f205fd 100644 --- a/services/clsi/app/coffee/TikzManager.coffee +++ b/services/clsi/app/coffee/TikzManager.coffee @@ -22,8 +22,8 @@ module.exports = TikzManager = _includesTikz: (resource) -> # check if we are using tikz externalize - content = resource.content.slice(0,65536) - if content.indexOf("\\tikzexternalize") >= 0 + content = resource.content?.slice(0,65536) + if content?.indexOf("\\tikzexternalize") >= 0 return true else return false diff --git a/services/clsi/test/unit/coffee/TikzManager.coffee b/services/clsi/test/unit/coffee/TikzManager.coffee index 8174b4a2e2..816b3b10cf 100644 --- a/services/clsi/test/unit/coffee/TikzManager.coffee +++ b/services/clsi/test/unit/coffee/TikzManager.coffee @@ -30,6 +30,12 @@ describe 'TikzManager', -> { path: 'output.tex' } ]).should.equal false + it "should return false if the file has no content", -> + @TikzManager.needsOutputFile("main.tex", [ + { path: 'foo.tex' }, + { path: 'main.tex' } + ]).should.equal false + describe "injectOutputFile", -> beforeEach -> @rootDir = "/mock" From d43357e8c817bd38b4d78c301cbfa5735c9a3782 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 18 Jul 2017 11:30:22 +0100 Subject: [PATCH 2/2] stub out unwanted dependency in unit tests --- services/clsi/test/unit/coffee/CompileManagerTests.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/clsi/test/unit/coffee/CompileManagerTests.coffee b/services/clsi/test/unit/coffee/CompileManagerTests.coffee index 68629a1c43..de33166406 100644 --- a/services/clsi/test/unit/coffee/CompileManagerTests.coffee +++ b/services/clsi/test/unit/coffee/CompileManagerTests.coffee @@ -18,6 +18,7 @@ describe "CompileManager", -> "child_process": @child_process = {} "./CommandRunner": @CommandRunner = {} "./DraftModeManager": @DraftModeManager = {} + "./TikzManager": @TikzManager = {} "fs": @fs = {} @callback = sinon.stub() @@ -55,6 +56,7 @@ describe "CompileManager", -> @OutputFileFinder.findOutputFiles = sinon.stub().callsArgWith(2, null, @output_files) @OutputCacheManager.saveOutputFiles = sinon.stub().callsArgWith(2, null, @build_files) @DraftModeManager.injectDraftMode = sinon.stub().callsArg(1) + @TikzManager.needsOutputFile = sinon.stub().returns(false) describe "normally", -> beforeEach ->