RestoreManagerTests.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* eslint-disable
  2. no-return-assign,
  3. no-unused-vars,
  4. */
  5. // TODO: This file was created by bulk-decaffeinate.
  6. // Fix any style issues and re-enable lint.
  7. /*
  8. * decaffeinate suggestions:
  9. * DS102: Remove unnecessary code created because of implicit returns
  10. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  11. */
  12. const sinon = require('sinon')
  13. const { expect } = require('chai')
  14. const modulePath = '../../../../app/js/RestoreManager.js'
  15. const SandboxedModule = require('sandboxed-module')
  16. describe('RestoreManager', function () {
  17. beforeEach(function () {
  18. this.RestoreManager = SandboxedModule.require(modulePath, {
  19. requires: {
  20. './DocumentUpdaterManager': (this.DocumentUpdaterManager = {}),
  21. './DiffManager': (this.DiffManager = {}),
  22. },
  23. })
  24. this.callback = sinon.stub()
  25. this.project_id = 'mock-project-id'
  26. this.doc_id = 'mock-doc-id'
  27. this.user_id = 'mock-user-id'
  28. return (this.version = 42)
  29. })
  30. return describe('restoreToBeforeVersion', function () {
  31. beforeEach(function () {
  32. this.content = 'mock content'
  33. this.DocumentUpdaterManager.setDocument = sinon.stub().callsArg(4)
  34. this.DiffManager.getDocumentBeforeVersion = sinon
  35. .stub()
  36. .callsArgWith(3, null, this.content)
  37. return this.RestoreManager.restoreToBeforeVersion(
  38. this.project_id,
  39. this.doc_id,
  40. this.version,
  41. this.user_id,
  42. this.callback
  43. )
  44. })
  45. it('should get the content before the requested version', function () {
  46. return this.DiffManager.getDocumentBeforeVersion
  47. .calledWith(this.project_id, this.doc_id, this.version)
  48. .should.equal(true)
  49. })
  50. it('should set the document in the document updater', function () {
  51. return this.DocumentUpdaterManager.setDocument
  52. .calledWith(this.project_id, this.doc_id, this.content, this.user_id)
  53. .should.equal(true)
  54. })
  55. return it('should call the callback', function () {
  56. return this.callback.called.should.equal(true)
  57. })
  58. })
  59. })