mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
32 lines
860 B
CoffeeScript
32 lines
860 B
CoffeeScript
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
|
|
|
|
|
|
|