BrokenLatexFileTests.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* eslint-disable
  2. no-unused-vars,
  3. */
  4. // TODO: This file was created by bulk-decaffeinate.
  5. // Fix any style issues and re-enable lint.
  6. /*
  7. * decaffeinate suggestions:
  8. * DS102: Remove unnecessary code created because of implicit returns
  9. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  10. */
  11. const Client = require('./helpers/Client')
  12. const request = require('request')
  13. const ClsiApp = require('./helpers/ClsiApp')
  14. const { expect } = require('chai')
  15. describe('Broken LaTeX file', function () {
  16. before(function (done) {
  17. this.broken_request = {
  18. resources: [
  19. {
  20. path: 'main.tex',
  21. content: `\
  22. \\documentclass{articl % :(
  23. \\begin{documen % :(
  24. Broken
  25. \\end{documen % :(\
  26. `,
  27. },
  28. ],
  29. }
  30. this.correct_request = {
  31. resources: [
  32. {
  33. path: 'main.tex',
  34. content: `\
  35. \\documentclass{article}
  36. \\begin{document}
  37. Hello world
  38. \\end{document}\
  39. `,
  40. },
  41. ],
  42. }
  43. return ClsiApp.ensureRunning(done)
  44. })
  45. describe('on first run', function () {
  46. before(function (done) {
  47. this.project_id = Client.randomId()
  48. return Client.compile(
  49. this.project_id,
  50. this.broken_request,
  51. (error, res, body) => {
  52. this.error = error
  53. this.res = res
  54. this.body = body
  55. return done()
  56. }
  57. )
  58. })
  59. it('should return a failure status', function () {
  60. return this.body.compile.status.should.equal('failure')
  61. })
  62. it('should return isInitialCompile flag', function () {
  63. expect(this.body.compile.stats.isInitialCompile).to.equal(1)
  64. })
  65. it('should return output files', function () {
  66. // NOTE: No output.pdf file.
  67. this.body.compile.outputFiles
  68. .map(f => f.path)
  69. .should.deep.equal([
  70. 'output.aux',
  71. 'output.fdb_latexmk',
  72. 'output.fls',
  73. 'output.log',
  74. 'output.stderr',
  75. 'output.stdout',
  76. ])
  77. })
  78. })
  79. return describe('on second run', function () {
  80. before(function (done) {
  81. this.project_id = Client.randomId()
  82. return Client.compile(this.project_id, this.correct_request, () => {
  83. return Client.compile(
  84. this.project_id,
  85. this.broken_request,
  86. (error, res, body) => {
  87. this.error = error
  88. this.res = res
  89. this.body = body
  90. return done()
  91. }
  92. )
  93. })
  94. })
  95. it('should return a failure status', function () {
  96. return this.body.compile.status.should.equal('failure')
  97. })
  98. it('should not return isInitialCompile flag', function () {
  99. expect(this.body.compile.stats.isInitialCompile).to.not.exist
  100. })
  101. it('should return output files', function () {
  102. // NOTE: No output.pdf file.
  103. this.body.compile.outputFiles
  104. .map(f => f.path)
  105. .should.deep.equal([
  106. 'output.aux',
  107. 'output.fdb_latexmk',
  108. 'output.fls',
  109. 'output.log',
  110. 'output.stderr',
  111. 'output.stdout',
  112. ])
  113. })
  114. })
  115. })