KeybuilderTests.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. const SandboxedModule = require('sandboxed-module')
  2. const modulePath = '../../../app/js/KeyBuilder.js'
  3. describe('KeybuilderTests', function () {
  4. let KeyBuilder
  5. const key = 'wombat/potato'
  6. beforeEach(function () {
  7. KeyBuilder = SandboxedModule.require(modulePath, {
  8. requires: { '@overleaf/settings': {} },
  9. })
  10. })
  11. describe('cachedKey', function () {
  12. it('should add the format to the key', function () {
  13. const opts = { format: 'png' }
  14. const newKey = KeyBuilder.addCachingToKey(key, opts)
  15. newKey.should.equal(`${key}-converted-cache/format-png`)
  16. })
  17. it('should add the style to the key', function () {
  18. const opts = { style: 'thumbnail' }
  19. const newKey = KeyBuilder.addCachingToKey(key, opts)
  20. newKey.should.equal(`${key}-converted-cache/style-thumbnail`)
  21. })
  22. it('should add format first, then style', function () {
  23. const opts = {
  24. style: 'thumbnail',
  25. format: 'png',
  26. }
  27. const newKey = KeyBuilder.addCachingToKey(key, opts)
  28. newKey.should.equal(`${key}-converted-cache/format-png-style-thumbnail`)
  29. })
  30. })
  31. })