RedisWrapperTests.coffee 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. assert = require("chai").assert
  2. sinon = require('sinon')
  3. chai = require('chai')
  4. should = chai.should()
  5. expect = chai.expect
  6. modulePath = "../../../../app/js/infrastructure/RedisWrapper.js"
  7. SandboxedModule = require('sandboxed-module')
  8. describe 'RedisWrapper', ->
  9. beforeEach ->
  10. @settings = { redis: {} }
  11. @redis =
  12. createClient: sinon.stub()
  13. @RedisWrapper = SandboxedModule.require modulePath, requires:
  14. 'settings-sharelatex': @settings
  15. 'redis-sharelatex': @redis
  16. describe 'client', ->
  17. it "should use the feature settings if present", ->
  18. @settings.redis =
  19. my_feature:
  20. port:"23456"
  21. host:"otherhost"
  22. password: "banana"
  23. @RedisWrapper.client("my_feature")
  24. @redis.createClient.calledWith(@settings.redis.my_feature).should.equal true
  25. it "should use the web settings if feature not present", ->
  26. @settings.redis =
  27. web:
  28. port:"43"
  29. host:"otherhost"
  30. password: "banana"
  31. @RedisWrapper.client("my_feature")
  32. @redis.createClient.calledWith(@settings.redis.web).should.equal true