KeybuilderTests.coffee 998 B

123456789101112131415161718192021222324252627282930313233343536373839
  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/KeyBuilder.js"
  7. SandboxedModule = require('sandboxed-module')
  8. describe "LocalFileWriter", ->
  9. beforeEach ->
  10. @keyBuilder = SandboxedModule.require modulePath, requires:
  11. "logger-sharelatex":
  12. log:->
  13. err:->
  14. @key = "123/456"
  15. describe "cachedKey", ->
  16. it "should add the fomat on", ->
  17. opts =
  18. format: "png"
  19. newKey = @keyBuilder.addCachingToKey @key, opts
  20. newKey.should.equal "#{@key}-converted-cache/format-png"
  21. it "should add the style on", ->
  22. opts =
  23. style: "thumbnail"
  24. newKey = @keyBuilder.addCachingToKey @key, opts
  25. newKey.should.equal "#{@key}-converted-cache/style-thumbnail"
  26. it "should add format on first", ->
  27. opts =
  28. style: "thumbnail"
  29. format: "png"
  30. newKey = @keyBuilder.addCachingToKey @key, opts
  31. newKey.should.equal "#{@key}-converted-cache/format-png-style-thumbnail"