getDocsWithPendingUpdatesTests.coffee 985 B

12345678910111213141516171819202122232425262728293031323334
  1. sinon = require('sinon')
  2. chai = require('chai')
  3. should = chai.should()
  4. modulePath = "../../../../app/js/RedisManager"
  5. SandboxedModule = require('sandboxed-module')
  6. describe "RedisManager.getDocsWithPendingUpdates", ->
  7. beforeEach ->
  8. @callback = sinon.stub()
  9. @RedisManager = SandboxedModule.require modulePath, requires:
  10. "redis-sharelatex" : createClient: () =>
  11. @rclient ?= auth:->
  12. "logger-sharelatex": {}
  13. @docs = [{
  14. doc_id: "doc-id-1"
  15. project_id: "project-id-1"
  16. }, {
  17. doc_id: "doc-id-2"
  18. project_id: "project-id-2"
  19. }]
  20. @doc_keys = @docs.map (doc) -> "#{doc.project_id}:#{doc.doc_id}"
  21. @rclient.smembers = sinon.stub().callsArgWith(1, null, @doc_keys)
  22. @RedisManager.getDocsWithPendingUpdates(@callback)
  23. it "should get the docs with pending updates", ->
  24. @rclient.smembers
  25. .calledWith("DocsWithPendingUpdates")
  26. .should.equal true
  27. it "should return the docs with pending updates", ->
  28. @callback.calledWith(null, @docs).should.equal true