BrokenLatexFileTests.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import Client from './helpers/Client.js'
  2. import ClsiApp from './helpers/ClsiApp.js'
  3. import { expect } from 'chai'
  4. describe('Broken LaTeX file', function () {
  5. before(async function () {
  6. this.broken_request = {
  7. resources: [
  8. {
  9. path: 'main.tex',
  10. content: `\
  11. \\documentclass{articl % :(
  12. \\begin{documen % :(
  13. Broken
  14. \\end{documen % :(\
  15. `,
  16. },
  17. ],
  18. }
  19. this.correct_request = {
  20. resources: [
  21. {
  22. path: 'main.tex',
  23. content: `\
  24. \\documentclass{article}
  25. \\begin{document}
  26. Hello world
  27. \\end{document}\
  28. `,
  29. },
  30. ],
  31. }
  32. await ClsiApp.ensureRunning()
  33. })
  34. describe('on first run', function () {
  35. before(async function () {
  36. this.project_id = Client.randomId()
  37. this.body = await Client.compile(this.project_id, this.broken_request)
  38. })
  39. it('should return a failure status', function () {
  40. this.body.compile.status.should.equal('failure')
  41. })
  42. it('should return isInitialCompile flag', function () {
  43. expect(this.body.compile.stats.isInitialCompile).to.equal(1)
  44. })
  45. it('should return output files', function () {
  46. // NOTE: No output.pdf file.
  47. this.body.compile.outputFiles
  48. .map(f => f.path)
  49. .should.deep.equal([
  50. 'output.aux',
  51. 'output.fdb_latexmk',
  52. 'output.fls',
  53. 'output.log',
  54. 'output.stderr',
  55. 'output.stdout',
  56. ])
  57. })
  58. })
  59. describe('on second run', function () {
  60. before(async function () {
  61. this.project_id = Client.randomId()
  62. await Client.compile(this.project_id, this.correct_request)
  63. this.body = await Client.compile(this.project_id, this.broken_request)
  64. })
  65. it('should return a failure status', function () {
  66. this.body.compile.status.should.equal('failure')
  67. })
  68. it('should not return isInitialCompile flag', function () {
  69. expect(this.body.compile.stats.isInitialCompile).to.not.exist
  70. })
  71. it('should return output files', function () {
  72. // NOTE: No output.pdf file.
  73. this.body.compile.outputFiles
  74. .map(f => f.path)
  75. .should.deep.equal([
  76. 'output.aux',
  77. 'output.fdb_latexmk',
  78. 'output.fls',
  79. 'output.log',
  80. 'output.stderr',
  81. 'output.stdout',
  82. ])
  83. })
  84. })
  85. })