mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
44 lines
1.2 KiB
CoffeeScript
44 lines
1.2 KiB
CoffeeScript
|
sinon = require('sinon')
|
||
|
chai = require('chai')
|
||
|
should = chai.should()
|
||
|
modulePath = "../../../../app/js/RedisManager.js"
|
||
|
SandboxedModule = require('sandboxed-module')
|
||
|
|
||
|
describe "RedisManager.getHistoryLoadManagerThreshold", ->
|
||
|
beforeEach ->
|
||
|
@RedisManager = SandboxedModule.require modulePath, requires:
|
||
|
"redis": createClient: () =>
|
||
|
@rclient =
|
||
|
auth: () ->
|
||
|
"logger-sharelatex": @logger = {log: sinon.stub()}
|
||
|
@callback = sinon.stub()
|
||
|
|
||
|
describe "with no value", ->
|
||
|
beforeEach ->
|
||
|
@rclient.get = sinon.stub().callsArgWith(1, null, null)
|
||
|
@RedisManager.getHistoryLoadManagerThreshold @callback
|
||
|
|
||
|
it "should get the value", ->
|
||
|
@rclient.get
|
||
|
.calledWith("HistoryLoadManagerThreshold")
|
||
|
.should.equal true
|
||
|
|
||
|
it "should call the callback with 0", ->
|
||
|
@callback.calledWith(null, 0).should.equal true
|
||
|
|
||
|
describe "with a value", ->
|
||
|
beforeEach ->
|
||
|
@rclient.get = sinon.stub().callsArgWith(1, null, "42")
|
||
|
@RedisManager.getHistoryLoadManagerThreshold @callback
|
||
|
|
||
|
it "should get the value", ->
|
||
|
@rclient.get
|
||
|
.calledWith("HistoryLoadManagerThreshold")
|
||
|
.should.equal true
|
||
|
|
||
|
it "should call the callback with the numeric value", ->
|
||
|
@callback.calledWith(null, 42).should.equal true
|
||
|
|
||
|
|
||
|
|