DocLinesComparitorTests.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* eslint-disable
  2. max-len,
  3. mocha/no-identical-title,
  4. no-return-assign,
  5. no-unused-vars,
  6. */
  7. // TODO: This file was created by bulk-decaffeinate.
  8. // Fix any style issues and re-enable lint.
  9. /*
  10. * decaffeinate suggestions:
  11. * DS102: Remove unnecessary code created because of implicit returns
  12. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  13. */
  14. const sinon = require('sinon')
  15. const chai = require('chai')
  16. const should = chai.should()
  17. const modulePath = '../../../../app/src/Features/Project/DocLinesComparitor.js'
  18. const SandboxedModule = require('sandboxed-module')
  19. describe('doc lines comparitor', function() {
  20. beforeEach(function() {
  21. return (this.comparitor = SandboxedModule.require(modulePath, {
  22. globals: {
  23. console: console
  24. },
  25. requires: {
  26. 'logger-sharelatex': { log() {} }
  27. }
  28. }))
  29. })
  30. it('should return true when the lines are the same', function() {
  31. const lines1 = ['hello', 'world']
  32. const lines2 = ['hello', 'world']
  33. const result = this.comparitor.areSame(lines1, lines2)
  34. return result.should.equal(true)
  35. })
  36. it('should return false when the lines are different', function() {
  37. const lines1 = ['hello', 'world']
  38. const lines2 = ['diff', 'world']
  39. const result = this.comparitor.areSame(lines1, lines2)
  40. return result.should.equal(false)
  41. })
  42. it('should return false when the lines are different', function() {
  43. const lines1 = ['hello', 'world']
  44. const lines2 = ['hello', 'wrld']
  45. const result = this.comparitor.areSame(lines1, lines2)
  46. return result.should.equal(false)
  47. })
  48. it('should return true when the lines are same', function() {
  49. const lines1 = ['hello', 'world']
  50. const lines2 = ['hello', 'world']
  51. const result = this.comparitor.areSame(lines1, lines2)
  52. return result.should.equal(true)
  53. })
  54. it('should return false if the doc lines are different in length', function() {
  55. const lines1 = ['hello', 'world']
  56. const lines2 = ['hello', 'world', 'please']
  57. const result = this.comparitor.areSame(lines1, lines2)
  58. return result.should.equal(false)
  59. })
  60. it('should return false if the first array is undefined', function() {
  61. const lines1 = undefined
  62. const lines2 = ['hello', 'world']
  63. const result = this.comparitor.areSame(lines1, lines2)
  64. return result.should.equal(false)
  65. })
  66. it('should return false if the second array is undefined', function() {
  67. const lines1 = ['hello']
  68. const lines2 = undefined
  69. const result = this.comparitor.areSame(lines1, lines2)
  70. return result.should.equal(false)
  71. })
  72. it('should return false if the second array is not an array', function() {
  73. const lines1 = ['hello']
  74. const lines2 = ''
  75. const result = this.comparitor.areSame(lines1, lines2)
  76. return result.should.equal(false)
  77. })
  78. it('should return true when comparing equal orchard docs', function() {
  79. const lines1 = [{ text: 'hello world' }]
  80. const lines2 = [{ text: 'hello world' }]
  81. const result = this.comparitor.areSame(lines1, lines2)
  82. return result.should.equal(true)
  83. })
  84. it('should return false when comparing different orchard docs', function() {
  85. const lines1 = [{ text: 'goodbye world' }]
  86. const lines2 = [{ text: 'hello world' }]
  87. const result = this.comparitor.areSame(lines1, lines2)
  88. return result.should.equal(false)
  89. })
  90. })