mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
57 lines
1.6 KiB
CoffeeScript
57 lines
1.6 KiB
CoffeeScript
|
SandboxedModule = require('sandboxed-module')
|
||
|
sinon = require('sinon')
|
||
|
require('chai').should()
|
||
|
modulePath = require('path').join __dirname, '../../../app/js/LatexRunner'
|
||
|
Path = require "path"
|
||
|
|
||
|
describe "LatexRunner", ->
|
||
|
beforeEach ->
|
||
|
@LatexRunner = SandboxedModule.require modulePath, requires:
|
||
|
"settings-sharelatex": @Settings =
|
||
|
docker:
|
||
|
socketPath: "/var/run/docker.sock"
|
||
|
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
|
||
|
"./Metrics":
|
||
|
Timer: class Timer
|
||
|
done: () ->
|
||
|
"./CommandRunner": @CommandRunner = {}
|
||
|
|
||
|
@directory = "/local/compile/directory"
|
||
|
@mainFile = "main-file.tex"
|
||
|
@compiler = "pdflatex"
|
||
|
@callback = sinon.stub()
|
||
|
@project_id = "project-id-123"
|
||
|
|
||
|
describe "runLatex", ->
|
||
|
beforeEach ->
|
||
|
@CommandRunner.run = sinon.stub().callsArg(4)
|
||
|
|
||
|
describe "normally", ->
|
||
|
beforeEach ->
|
||
|
@LatexRunner.runLatex @project_id,
|
||
|
directory: @directory
|
||
|
mainFile: @mainFile
|
||
|
compiler: @compiler
|
||
|
timeout: @timeout = 42000
|
||
|
@callback
|
||
|
|
||
|
it "should run the latex command", ->
|
||
|
@CommandRunner.run
|
||
|
.calledWith(@project_id, sinon.match.any, @directory, @timeout)
|
||
|
.should.equal true
|
||
|
|
||
|
describe "with an .Rtex main file", ->
|
||
|
beforeEach ->
|
||
|
@LatexRunner.runLatex @project_id,
|
||
|
directory: @directory
|
||
|
mainFile: "main-file.Rtex"
|
||
|
compiler: @compiler
|
||
|
timeout: @timeout = 42000
|
||
|
@callback
|
||
|
|
||
|
it "should run the latex command on the equivalent .tex file", ->
|
||
|
command = @CommandRunner.run.args[0][1]
|
||
|
mainFile = command.slice(-1)[0]
|
||
|
mainFile.should.equal "$COMPILE_DIR/main-file.tex"
|
||
|
|