KeybuilderTests.js 1.0 KB

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