SimpleLatexFileTests.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Fix any style issues and re-enable lint.
  3. /*
  4. * decaffeinate suggestions:
  5. * DS102: Remove unnecessary code created because of implicit returns
  6. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  7. */
  8. const Client = require('./helpers/Client')
  9. const request = require('request')
  10. const ClsiApp = require('./helpers/ClsiApp')
  11. describe('Simple LaTeX file', function () {
  12. before(function (done) {
  13. this.project_id = Client.randomId()
  14. this.request = {
  15. resources: [
  16. {
  17. path: 'main.tex',
  18. content: `\
  19. \\documentclass{article}
  20. \\begin{document}
  21. Hello world
  22. \\end{document}\
  23. `,
  24. },
  25. ],
  26. }
  27. return ClsiApp.ensureRunning(() => {
  28. return Client.compile(
  29. this.project_id,
  30. this.request,
  31. (error, res, body) => {
  32. this.error = error
  33. this.res = res
  34. this.body = body
  35. return done()
  36. }
  37. )
  38. })
  39. })
  40. it('should return the PDF', function () {
  41. const pdf = Client.getOutputFile(this.body, 'pdf')
  42. return pdf.type.should.equal('pdf')
  43. })
  44. it('should return the log', function () {
  45. const log = Client.getOutputFile(this.body, 'log')
  46. return log.type.should.equal('log')
  47. })
  48. it('should provide the pdf for download', function (done) {
  49. const pdf = Client.getOutputFile(this.body, 'pdf')
  50. return request.get(pdf.url, (error, res, body) => {
  51. if (error) return done(error)
  52. res.statusCode.should.equal(200)
  53. return done()
  54. })
  55. })
  56. return it('should provide the log for download', function (done) {
  57. const log = Client.getOutputFile(this.body, 'pdf')
  58. return request.get(log.url, (error, res, body) => {
  59. if (error) return done(error)
  60. res.statusCode.should.equal(200)
  61. return done()
  62. })
  63. })
  64. })