WordcountTests.js 1.8 KB

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