| 1234567891011121314151617181920212223242526272829303132 |
- sinon = require('sinon')
- chai = require('chai')
- should = chai.should()
- modulePath = "../../../../app/js/RedisManager"
- SandboxedModule = require('sandboxed-module')
- describe "RedisManager.clearDocFromPendingUpdatesSet", ->
- beforeEach ->
- @doc_id = "document-id"
- @callback = sinon.stub()
- @RedisManager = SandboxedModule.require modulePath, requires:
- "redis" : createClient: () =>
- @rclient = auth:->
- @rclient.lpush = sinon.stub().callsArg(2)
- @ops = [
- { "mock" : "op-1" },
- { "mock" : "op-2" }
- ]
- @reversedJsonOps = @ops.map((op) -> JSON.stringify op).reverse()
- @RedisManager.prependDocOps(@doc_id, @ops, @callback)
- it "should push the reversed JSONed ops", ->
- @rclient.lpush
- .calledWith("DocOps:#{@doc_id}", @reversedJsonOps)
- .should.equal true
-
- it "should return the callback", ->
- @callback.called.should.equal true
|