2020-01-02 11:12:07 -05:00
|
|
|
const SandboxedModule = require('sandboxed-module')
|
2014-02-14 11:39:05 -05:00
|
|
|
|
2019-12-16 06:20:29 -05:00
|
|
|
const modulePath = '../../../app/js/KeyBuilder.js'
|
2014-02-14 11:39:05 -05:00
|
|
|
|
2020-08-10 12:01:12 -04:00
|
|
|
describe('KeybuilderTests', function () {
|
2020-01-02 11:12:07 -05:00
|
|
|
let KeyBuilder
|
|
|
|
const key = 'wombat/potato'
|
|
|
|
|
2020-08-10 12:01:12 -04:00
|
|
|
beforeEach(function () {
|
2020-02-23 10:42:04 -05:00
|
|
|
KeyBuilder = SandboxedModule.require(modulePath, {
|
|
|
|
requires: { 'settings-sharelatex': {} }
|
|
|
|
})
|
2019-12-16 06:20:29 -05:00
|
|
|
})
|
2014-02-14 11:39:05 -05:00
|
|
|
|
2020-08-10 12:01:12 -04:00
|
|
|
describe('cachedKey', function () {
|
|
|
|
it('should add the format to the key', function () {
|
2019-12-16 06:20:29 -05:00
|
|
|
const opts = { format: 'png' }
|
2020-01-02 11:12:07 -05:00
|
|
|
const newKey = KeyBuilder.addCachingToKey(key, opts)
|
|
|
|
newKey.should.equal(`${key}-converted-cache/format-png`)
|
2019-12-16 06:20:29 -05:00
|
|
|
})
|
2014-02-14 11:39:05 -05:00
|
|
|
|
2020-08-10 12:01:12 -04:00
|
|
|
it('should add the style to the key', function () {
|
2019-12-16 06:20:29 -05:00
|
|
|
const opts = { style: 'thumbnail' }
|
2020-01-02 11:12:07 -05:00
|
|
|
const newKey = KeyBuilder.addCachingToKey(key, opts)
|
|
|
|
newKey.should.equal(`${key}-converted-cache/style-thumbnail`)
|
2019-12-16 06:20:29 -05:00
|
|
|
})
|
2014-02-14 11:39:05 -05:00
|
|
|
|
2020-08-10 12:01:12 -04:00
|
|
|
it('should add format first, then style', function () {
|
2019-12-16 06:20:29 -05:00
|
|
|
const opts = {
|
|
|
|
style: 'thumbnail',
|
|
|
|
format: 'png'
|
|
|
|
}
|
2020-01-02 11:12:07 -05:00
|
|
|
const newKey = KeyBuilder.addCachingToKey(key, opts)
|
|
|
|
newKey.should.equal(`${key}-converted-cache/format-png-style-thumbnail`)
|
2019-12-16 06:20:29 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|