Support configurable images in wordcount end point

This commit is contained in:
James Allen
2016-01-19 14:12:41 +00:00
parent 4497352a3a
commit 86cf05c732
4 changed files with 13 additions and 9 deletions

View File

@@ -197,14 +197,15 @@ describe "CompileController", ->
project_id: @project_id
@req.query =
file: @file
image: @image = "example.com/image"
@res.send = sinon.stub()
@CompileManager.wordcount = sinon.stub().callsArgWith(2, null, @texcount = ["mock-texcount"])
@CompileManager.wordcount = sinon.stub().callsArgWith(3, null, @texcount = ["mock-texcount"])
@CompileController.wordcount @req, @res, @next
it "should return the word count of a file", ->
@CompileManager.wordcount
.calledWith(@project_id, @file)
.calledWith(@project_id, @file, @image)
.should.equal true
it "should return the texcount info", ->

View File

@@ -179,7 +179,7 @@ describe "CompileManager", ->
describe "wordcount", ->
beforeEach ->
@CommandRunner.run = sinon.stub().callsArg(4)
@CommandRunner.run = sinon.stub().callsArg(5)
@fs.readFileSync = sinon.stub().returns @stdout = "Encoding: ascii\nWords in text: 2"
@callback = sinon.stub()
@@ -187,8 +187,9 @@ describe "CompileManager", ->
@timeout = 10 * 1000
@file_name = "main.tex"
@Settings.path.compilesDir = "/local/compile/directory"
@image = "example.com/image"
@CompileManager.wordcount @project_id, @file_name, @callback
@CompileManager.wordcount @project_id, @file_name, @image, @callback
it "should run the texcount command", ->
@directory = "#{@Settings.path.compilesDir}/#{@project_id}"
@@ -196,7 +197,7 @@ describe "CompileManager", ->
@command =[ "texcount", "-inc", @file_path, "-out=" + @file_path + ".wc"]
@CommandRunner.run
.calledWith(@project_id, @command, @directory, @timeout)
.calledWith(@project_id, @command, @directory, @image, @timeout)
.should.equal true
it "should call the callback with the parsed output", ->