WordcountTests.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. * DS207: Consider shorter variations of null checks
  10. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  11. */
  12. const Client = require('./helpers/Client')
  13. const request = require('request')
  14. require('chai').should()
  15. const { expect } = require('chai')
  16. const path = require('path')
  17. const fs = require('fs')
  18. const ClsiApp = require('./helpers/ClsiApp')
  19. describe('Syncing', function () {
  20. before(function (done) {
  21. this.request = {
  22. resources: [
  23. {
  24. path: 'main.tex',
  25. content: fs.readFileSync(
  26. path.join(__dirname, '../fixtures/naugty_strings.txt'),
  27. 'utf-8'
  28. )
  29. }
  30. ]
  31. }
  32. this.project_id = Client.randomId()
  33. return ClsiApp.ensureRunning(() => {
  34. return Client.compile(
  35. this.project_id,
  36. this.request,
  37. (error, res, body) => {
  38. this.error = error
  39. this.res = res
  40. this.body = body
  41. return done()
  42. }
  43. )
  44. })
  45. })
  46. return describe('wordcount file', function () {
  47. return it('should return wordcount info', function (done) {
  48. return Client.wordcount(this.project_id, 'main.tex', (error, result) => {
  49. if (error != null) {
  50. throw error
  51. }
  52. expect(result).to.deep.equal({
  53. texcount: {
  54. encode: 'utf8',
  55. textWords: 2281,
  56. headWords: 2,
  57. outside: 0,
  58. headers: 2,
  59. elements: 0,
  60. mathInline: 6,
  61. mathDisplay: 0,
  62. errors: 0,
  63. messages: ''
  64. }
  65. })
  66. return done()
  67. })
  68. })
  69. })
  70. })