DocLinesComparitorTests.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 modulePath = '../../../../app/src/Features/Project/DocLinesComparitor.js'
  16. const SandboxedModule = require('sandboxed-module')
  17. describe('doc lines comparitor', function () {
  18. beforeEach(function () {
  19. return (this.comparitor = SandboxedModule.require(modulePath, {}))
  20. })
  21. it('should return true when the lines are the same', function () {
  22. const lines1 = ['hello', 'world']
  23. const lines2 = ['hello', 'world']
  24. const result = this.comparitor.areSame(lines1, lines2)
  25. return result.should.equal(true)
  26. })
  27. it('should return false when the lines are different', function () {
  28. const lines1 = ['hello', 'world']
  29. const lines2 = ['diff', 'world']
  30. const result = this.comparitor.areSame(lines1, lines2)
  31. return result.should.equal(false)
  32. })
  33. it('should return false when the lines are different', function () {
  34. const lines1 = ['hello', 'world']
  35. const lines2 = ['hello', 'wrld']
  36. const result = this.comparitor.areSame(lines1, lines2)
  37. return result.should.equal(false)
  38. })
  39. it('should return true when the lines are same', function () {
  40. const lines1 = ['hello', 'world']
  41. const lines2 = ['hello', 'world']
  42. const result = this.comparitor.areSame(lines1, lines2)
  43. return result.should.equal(true)
  44. })
  45. it('should return false if the doc lines are different in length', function () {
  46. const lines1 = ['hello', 'world']
  47. const lines2 = ['hello', 'world', 'please']
  48. const result = this.comparitor.areSame(lines1, lines2)
  49. return result.should.equal(false)
  50. })
  51. it('should return false if the first array is undefined', function () {
  52. const lines1 = undefined
  53. const lines2 = ['hello', 'world']
  54. const result = this.comparitor.areSame(lines1, lines2)
  55. return result.should.equal(false)
  56. })
  57. it('should return false if the second array is undefined', function () {
  58. const lines1 = ['hello']
  59. const lines2 = undefined
  60. const result = this.comparitor.areSame(lines1, lines2)
  61. return result.should.equal(false)
  62. })
  63. it('should return false if the second array is not an array', function () {
  64. const lines1 = ['hello']
  65. const lines2 = ''
  66. const result = this.comparitor.areSame(lines1, lines2)
  67. return result.should.equal(false)
  68. })
  69. it('should return true when comparing equal orchard docs', function () {
  70. const lines1 = [{ text: 'hello world' }]
  71. const lines2 = [{ text: 'hello world' }]
  72. const result = this.comparitor.areSame(lines1, lines2)
  73. return result.should.equal(true)
  74. })
  75. it('should return false when comparing different orchard docs', function () {
  76. const lines1 = [{ text: 'goodbye world' }]
  77. const lines2 = [{ text: 'hello world' }]
  78. const result = this.comparitor.areSame(lines1, lines2)
  79. return result.should.equal(false)
  80. })
  81. })