SimpleLatexFileTests.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* eslint-disable
  2. handle-callback-err,
  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. require('chai').should()
  14. const ClsiApp = require('./helpers/ClsiApp')
  15. describe('Simple LaTeX file', function () {
  16. before(function (done) {
  17. this.project_id = Client.randomId()
  18. this.request = {
  19. resources: [
  20. {
  21. path: 'main.tex',
  22. content: `\
  23. \\documentclass{article}
  24. \\begin{document}
  25. Hello world
  26. \\end{document}\
  27. `
  28. }
  29. ]
  30. }
  31. return ClsiApp.ensureRunning(() => {
  32. return Client.compile(
  33. this.project_id,
  34. this.request,
  35. (error, res, body) => {
  36. this.error = error
  37. this.res = res
  38. this.body = body
  39. return done()
  40. }
  41. )
  42. })
  43. })
  44. it('should return the PDF', function () {
  45. const pdf = Client.getOutputFile(this.body, 'pdf')
  46. return pdf.type.should.equal('pdf')
  47. })
  48. it('should return the log', function () {
  49. const log = Client.getOutputFile(this.body, 'log')
  50. return log.type.should.equal('log')
  51. })
  52. it('should provide the pdf for download', function (done) {
  53. const pdf = Client.getOutputFile(this.body, 'pdf')
  54. return request.get(pdf.url, (error, res, body) => {
  55. res.statusCode.should.equal(200)
  56. return done()
  57. })
  58. })
  59. return it('should provide the log for download', function (done) {
  60. const log = Client.getOutputFile(this.body, 'pdf')
  61. return request.get(log.url, (error, res, body) => {
  62. res.statusCode.should.equal(200)
  63. return done()
  64. })
  65. })
  66. })