mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
[misc] run format_fix and lint:fix
This commit is contained in:
@@ -23,7 +23,7 @@ const ChildProcess = require('child_process')
|
||||
const ClsiApp = require('./helpers/ClsiApp')
|
||||
const logger = require('logger-sharelatex')
|
||||
const Path = require('path')
|
||||
const fixturePath = (path) => {
|
||||
const fixturePath = path => {
|
||||
if (path.slice(0, 3) === 'tmp') {
|
||||
return '/tmp/clsi_acceptance_tests' + path.slice(3)
|
||||
}
|
||||
@@ -49,8 +49,8 @@ const convertToPng = function (pdfPath, pngPath, callback) {
|
||||
console.log(command)
|
||||
const convert = ChildProcess.exec(command)
|
||||
const stdout = ''
|
||||
convert.stdout.on('data', (chunk) => console.log('STDOUT', chunk.toString()))
|
||||
convert.stderr.on('data', (chunk) => console.log('STDERR', chunk.toString()))
|
||||
convert.stdout.on('data', chunk => console.log('STDOUT', chunk.toString()))
|
||||
convert.stderr.on('data', chunk => console.log('STDERR', chunk.toString()))
|
||||
return convert.on('exit', () => callback())
|
||||
}
|
||||
|
||||
@@ -65,11 +65,11 @@ const compare = function (originalPath, generatedPath, callback) {
|
||||
)} ${diff_file}`
|
||||
)
|
||||
let stderr = ''
|
||||
proc.stderr.on('data', (chunk) => (stderr += chunk))
|
||||
proc.stderr.on('data', chunk => (stderr += chunk))
|
||||
return proc.on('exit', () => {
|
||||
if (stderr.trim() === '0 (0)') {
|
||||
// remove output diff if test matches expected image
|
||||
fs.unlink(diff_file, (err) => {
|
||||
fs.unlink(diff_file, err => {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
@@ -88,8 +88,8 @@ const checkPdfInfo = function (pdfPath, callback) {
|
||||
}
|
||||
const proc = ChildProcess.exec(`pdfinfo ${fixturePath(pdfPath)}`)
|
||||
let stdout = ''
|
||||
proc.stdout.on('data', (chunk) => (stdout += chunk))
|
||||
proc.stderr.on('data', (chunk) => console.log('STDERR', chunk.toString()))
|
||||
proc.stdout.on('data', chunk => (stdout += chunk))
|
||||
proc.stderr.on('data', chunk => console.log('STDERR', chunk.toString()))
|
||||
return proc.on('exit', () => {
|
||||
if (stdout.match(/Optimized:\s+yes/)) {
|
||||
return callback(null, true)
|
||||
@@ -135,14 +135,14 @@ const comparePdf = function (project_id, example_dir, callback) {
|
||||
return convertToPng(
|
||||
`tmp/${project_id}.pdf`,
|
||||
`tmp/${project_id}-generated.png`,
|
||||
(error) => {
|
||||
error => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
return convertToPng(
|
||||
`examples/${example_dir}/output.pdf`,
|
||||
`tmp/${project_id}-source.png`,
|
||||
(error) => {
|
||||
error => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
@@ -162,7 +162,7 @@ const comparePdf = function (project_id, example_dir, callback) {
|
||||
}
|
||||
)
|
||||
} else {
|
||||
return compareMultiplePages(project_id, (error) => {
|
||||
return compareMultiplePages(project_id, error => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
@@ -216,82 +216,71 @@ describe('Example Documents', function () {
|
||||
fsExtra.remove(fixturePath('tmp'), done)
|
||||
})
|
||||
|
||||
return Array.from(fs.readdirSync(fixturePath('examples'))).map(
|
||||
(example_dir) =>
|
||||
((example_dir) =>
|
||||
describe(example_dir, function () {
|
||||
before(function () {
|
||||
return (this.project_id = Client.randomId() + '_' + example_dir)
|
||||
})
|
||||
return Array.from(fs.readdirSync(fixturePath('examples'))).map(example_dir =>
|
||||
(example_dir =>
|
||||
describe(example_dir, function () {
|
||||
before(function () {
|
||||
return (this.project_id = Client.randomId() + '_' + example_dir)
|
||||
})
|
||||
|
||||
it('should generate the correct pdf', function (done) {
|
||||
this.timeout(MOCHA_LATEX_TIMEOUT)
|
||||
return Client.compileDirectory(
|
||||
this.project_id,
|
||||
fixturePath('examples'),
|
||||
example_dir,
|
||||
4242,
|
||||
(error, res, body) => {
|
||||
if (
|
||||
error ||
|
||||
__guard__(
|
||||
body != null ? body.compile : undefined,
|
||||
(x) => x.status
|
||||
) === 'failure'
|
||||
) {
|
||||
console.log(
|
||||
'DEBUG: error',
|
||||
error,
|
||||
'body',
|
||||
JSON.stringify(body)
|
||||
)
|
||||
return done(new Error('Compile failed'))
|
||||
}
|
||||
const pdf = Client.getOutputFile(body, 'pdf')
|
||||
return downloadAndComparePdf(
|
||||
this.project_id,
|
||||
example_dir,
|
||||
pdf.url,
|
||||
done
|
||||
)
|
||||
it('should generate the correct pdf', function (done) {
|
||||
this.timeout(MOCHA_LATEX_TIMEOUT)
|
||||
return Client.compileDirectory(
|
||||
this.project_id,
|
||||
fixturePath('examples'),
|
||||
example_dir,
|
||||
4242,
|
||||
(error, res, body) => {
|
||||
if (
|
||||
error ||
|
||||
__guard__(
|
||||
body != null ? body.compile : undefined,
|
||||
x => x.status
|
||||
) === 'failure'
|
||||
) {
|
||||
console.log('DEBUG: error', error, 'body', JSON.stringify(body))
|
||||
return done(new Error('Compile failed'))
|
||||
}
|
||||
)
|
||||
})
|
||||
const pdf = Client.getOutputFile(body, 'pdf')
|
||||
return downloadAndComparePdf(
|
||||
this.project_id,
|
||||
example_dir,
|
||||
pdf.url,
|
||||
done
|
||||
)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
return it('should generate the correct pdf on the second run as well', function (done) {
|
||||
this.timeout(MOCHA_LATEX_TIMEOUT)
|
||||
return Client.compileDirectory(
|
||||
this.project_id,
|
||||
fixturePath('examples'),
|
||||
example_dir,
|
||||
4242,
|
||||
(error, res, body) => {
|
||||
if (
|
||||
error ||
|
||||
__guard__(
|
||||
body != null ? body.compile : undefined,
|
||||
(x) => x.status
|
||||
) === 'failure'
|
||||
) {
|
||||
console.log(
|
||||
'DEBUG: error',
|
||||
error,
|
||||
'body',
|
||||
JSON.stringify(body)
|
||||
)
|
||||
return done(new Error('Compile failed'))
|
||||
}
|
||||
const pdf = Client.getOutputFile(body, 'pdf')
|
||||
return downloadAndComparePdf(
|
||||
this.project_id,
|
||||
example_dir,
|
||||
pdf.url,
|
||||
done
|
||||
)
|
||||
return it('should generate the correct pdf on the second run as well', function (done) {
|
||||
this.timeout(MOCHA_LATEX_TIMEOUT)
|
||||
return Client.compileDirectory(
|
||||
this.project_id,
|
||||
fixturePath('examples'),
|
||||
example_dir,
|
||||
4242,
|
||||
(error, res, body) => {
|
||||
if (
|
||||
error ||
|
||||
__guard__(
|
||||
body != null ? body.compile : undefined,
|
||||
x => x.status
|
||||
) === 'failure'
|
||||
) {
|
||||
console.log('DEBUG: error', error, 'body', JSON.stringify(body))
|
||||
return done(new Error('Compile failed'))
|
||||
}
|
||||
)
|
||||
})
|
||||
}))(example_dir)
|
||||
const pdf = Client.getOutputFile(body, 'pdf')
|
||||
return downloadAndComparePdf(
|
||||
this.project_id,
|
||||
example_dir,
|
||||
pdf.url,
|
||||
done
|
||||
)
|
||||
}
|
||||
)
|
||||
})
|
||||
}))(example_dir)
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user