2020-02-19 06:16:07 -05:00
|
|
|
/* eslint-disable
|
|
|
|
no-unused-vars,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
2020-02-19 06:16:00 -05:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2020-02-19 06:16:14 -05:00
|
|
|
const Client = require('./helpers/Client')
|
|
|
|
const request = require('request')
|
|
|
|
const { expect } = require('chai')
|
|
|
|
const ClsiApp = require('./helpers/ClsiApp')
|
|
|
|
const crypto = require('crypto')
|
2014-04-08 10:18:56 -04:00
|
|
|
|
2020-08-10 12:01:11 -04:00
|
|
|
describe('Syncing', function () {
|
|
|
|
before(function (done) {
|
2020-02-19 06:16:14 -05:00
|
|
|
const content = `\
|
2020-02-19 06:16:00 -05:00
|
|
|
\\documentclass{article}
|
|
|
|
\\begin{document}
|
|
|
|
Hello world
|
|
|
|
\\end{document}\
|
2020-02-19 06:16:14 -05:00
|
|
|
`
|
|
|
|
this.request = {
|
|
|
|
resources: [
|
|
|
|
{
|
|
|
|
path: 'main.tex',
|
2021-07-13 07:04:48 -04:00
|
|
|
content,
|
|
|
|
},
|
|
|
|
],
|
2020-02-19 06:16:14 -05:00
|
|
|
}
|
|
|
|
this.project_id = Client.randomId()
|
|
|
|
return ClsiApp.ensureRunning(() => {
|
|
|
|
return Client.compile(
|
|
|
|
this.project_id,
|
|
|
|
this.request,
|
|
|
|
(error, res, body) => {
|
|
|
|
this.error = error
|
|
|
|
this.res = res
|
|
|
|
this.body = body
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
2014-04-08 10:18:56 -04:00
|
|
|
|
2020-08-10 12:01:11 -04:00
|
|
|
describe('from code to pdf', function () {
|
|
|
|
return it('should return the correct location', function (done) {
|
2020-02-19 06:16:14 -05:00
|
|
|
return Client.syncFromCode(
|
|
|
|
this.project_id,
|
|
|
|
'main.tex',
|
|
|
|
3,
|
|
|
|
5,
|
|
|
|
(error, pdfPositions) => {
|
|
|
|
if (error != null) {
|
|
|
|
throw error
|
|
|
|
}
|
|
|
|
expect(pdfPositions).to.deep.equal({
|
|
|
|
pdf: [
|
2021-07-13 07:04:48 -04:00
|
|
|
{ page: 1, h: 133.77, v: 134.76, height: 6.92, width: 343.71 },
|
|
|
|
],
|
2020-02-19 06:16:14 -05:00
|
|
|
})
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
2014-04-08 10:18:56 -04:00
|
|
|
|
2020-08-10 12:01:11 -04:00
|
|
|
describe('from pdf to code', function () {
|
|
|
|
return it('should return the correct location', function (done) {
|
2020-02-19 06:16:14 -05:00
|
|
|
return Client.syncFromPdf(
|
|
|
|
this.project_id,
|
|
|
|
1,
|
|
|
|
100,
|
|
|
|
200,
|
|
|
|
(error, codePositions) => {
|
|
|
|
if (error != null) {
|
|
|
|
throw error
|
|
|
|
}
|
|
|
|
expect(codePositions).to.deep.equal({
|
2021-07-13 07:04:48 -04:00
|
|
|
code: [{ file: 'main.tex', line: 3, column: -1 }],
|
2020-02-19 06:16:14 -05:00
|
|
|
})
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
2020-06-12 10:16:14 -04:00
|
|
|
|
2020-08-10 12:01:11 -04:00
|
|
|
describe('when the project directory is not available', function () {
|
|
|
|
before(function () {
|
2020-06-12 10:16:14 -04:00
|
|
|
this.other_project_id = Client.randomId()
|
|
|
|
})
|
2020-08-10 12:01:11 -04:00
|
|
|
describe('from code to pdf', function () {
|
|
|
|
it('should return a 404 response', function (done) {
|
2020-06-12 10:16:14 -04:00
|
|
|
return Client.syncFromCode(
|
|
|
|
this.other_project_id,
|
|
|
|
'main.tex',
|
|
|
|
3,
|
|
|
|
5,
|
|
|
|
(error, body) => {
|
2021-03-30 08:22:11 -04:00
|
|
|
expect(String(error)).to.include('statusCode=404')
|
2020-06-12 10:16:14 -04:00
|
|
|
expect(body).to.equal('Not Found')
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
2020-08-10 12:01:11 -04:00
|
|
|
describe('from pdf to code', function () {
|
|
|
|
it('should return a 404 response', function (done) {
|
2020-06-12 10:16:14 -04:00
|
|
|
return Client.syncFromPdf(
|
|
|
|
this.other_project_id,
|
|
|
|
1,
|
|
|
|
100,
|
|
|
|
200,
|
|
|
|
(error, body) => {
|
2021-03-30 08:22:11 -04:00
|
|
|
expect(String(error)).to.include('statusCode=404')
|
2020-06-12 10:16:14 -04:00
|
|
|
expect(body).to.equal('Not Found')
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-08-10 12:01:11 -04:00
|
|
|
describe('when the synctex file is not available', function () {
|
|
|
|
before(function (done) {
|
2020-06-12 10:16:14 -04:00
|
|
|
this.broken_project_id = Client.randomId()
|
|
|
|
const content = 'this is not valid tex' // not a valid tex file
|
|
|
|
this.request = {
|
|
|
|
resources: [
|
|
|
|
{
|
|
|
|
path: 'main.tex',
|
2021-07-13 07:04:48 -04:00
|
|
|
content,
|
|
|
|
},
|
|
|
|
],
|
2020-06-12 10:16:14 -04:00
|
|
|
}
|
|
|
|
Client.compile(
|
|
|
|
this.broken_project_id,
|
|
|
|
this.request,
|
|
|
|
(error, res, body) => {
|
|
|
|
this.error = error
|
|
|
|
this.res = res
|
|
|
|
this.body = body
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2020-08-10 12:01:11 -04:00
|
|
|
describe('from code to pdf', function () {
|
|
|
|
it('should return a 404 response', function (done) {
|
2020-06-12 10:16:14 -04:00
|
|
|
return Client.syncFromCode(
|
|
|
|
this.broken_project_id,
|
|
|
|
'main.tex',
|
|
|
|
3,
|
|
|
|
5,
|
|
|
|
(error, body) => {
|
2021-03-30 08:22:11 -04:00
|
|
|
expect(String(error)).to.include('statusCode=404')
|
2020-06-12 10:16:14 -04:00
|
|
|
expect(body).to.equal('Not Found')
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
2020-08-10 12:01:11 -04:00
|
|
|
describe('from pdf to code', function () {
|
|
|
|
it('should return a 404 response', function (done) {
|
2020-06-12 10:16:14 -04:00
|
|
|
return Client.syncFromPdf(
|
|
|
|
this.broken_project_id,
|
|
|
|
1,
|
|
|
|
100,
|
|
|
|
200,
|
|
|
|
(error, body) => {
|
2021-03-30 08:22:11 -04:00
|
|
|
expect(String(error)).to.include('statusCode=404')
|
2020-06-12 10:16:14 -04:00
|
|
|
expect(body).to.equal('Not Found')
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2020-02-19 06:16:14 -05:00
|
|
|
})
|