2014-04-08 10:18:56 -04:00
|
|
|
Client = require "./helpers/Client"
|
|
|
|
request = require "request"
|
|
|
|
require("chai").should()
|
|
|
|
expect = require("chai").expect
|
2018-02-16 06:36:32 -05:00
|
|
|
ClsiApp = require "./helpers/ClsiApp"
|
2018-03-01 08:55:55 -05:00
|
|
|
crypto = require("crypto")
|
2014-04-08 10:18:56 -04:00
|
|
|
|
|
|
|
describe "Syncing", ->
|
|
|
|
before (done) ->
|
2018-03-01 08:55:55 -05:00
|
|
|
content = '''
|
2014-04-08 10:18:56 -04:00
|
|
|
\\documentclass{article}
|
|
|
|
\\begin{document}
|
|
|
|
Hello world
|
|
|
|
\\end{document}
|
|
|
|
'''
|
2018-03-01 08:55:55 -05:00
|
|
|
@request =
|
|
|
|
resources: [
|
|
|
|
path: "main.tex"
|
|
|
|
content: content
|
2014-04-08 10:18:56 -04:00
|
|
|
]
|
|
|
|
@project_id = Client.randomId()
|
2018-02-16 06:36:32 -05:00
|
|
|
ClsiApp.ensureRunning =>
|
|
|
|
Client.compile @project_id, @request, (@error, @res, @body) => done()
|
2014-04-08 10:18:56 -04:00
|
|
|
|
2018-03-01 08:55:55 -05:00
|
|
|
describe "from code to pdf", ->
|
|
|
|
it "should return the correct location", (done) ->
|
|
|
|
Client.syncFromCode @project_id, "main.tex", 3, 5, (error, pdfPositions) ->
|
|
|
|
throw error if error?
|
|
|
|
expect(pdfPositions).to.deep.equal(
|
|
|
|
pdf: [ { page: 1, h: 133.77, v: 134.76, height: 6.92, width: 343.71 } ]
|
|
|
|
)
|
|
|
|
done()
|
2014-04-08 10:18:56 -04:00
|
|
|
|
|
|
|
describe "from pdf to code", ->
|
|
|
|
it "should return the correct location", (done) ->
|
2018-03-01 08:55:55 -05:00
|
|
|
Client.syncFromPdf @project_id, 1, 100, 200, (error, codePositions) =>
|
2014-04-08 10:18:56 -04:00
|
|
|
throw error if error?
|
|
|
|
expect(codePositions).to.deep.equal(
|
|
|
|
code: [ { file: 'main.tex', line: 3, column: -1 } ]
|
|
|
|
)
|
|
|
|
done()
|