Files
overleaf-cep/services/filestore/test/unit/js/Keybuilder.test.js
Andrew Rumble 90cf4b6a0a Merge pull request #29841 from overleaf/ar-convert-filestore-to-esm
[filestore] convert to ES modules

GitOrigin-RevId: 404905973548bb6e437fff66b368e87be8249b73
2025-12-05 09:05:35 +00:00

42 lines
1.2 KiB
JavaScript

import { beforeEach, describe, expect, it, vi } from 'vitest'
const modulePath = '../../../app/js/KeyBuilder.js'
describe('KeybuilderTests', function () {
let KeyBuilder
const key = 'wombat/potato'
beforeEach(async function () {
vi.doMock('@overleaf/settings', () => ({
default: {},
}))
KeyBuilder = (await import(modulePath)).default
})
describe('cachedKey', function () {
it('should add the format to the key', function () {
const opts = { format: 'png' }
const newKey = KeyBuilder.addCachingToKey(key, opts)
expect(newKey).to.equal(`${key}-converted-cache/format-png`)
})
it('should add the style to the key', function () {
const opts = { style: 'thumbnail' }
const newKey = KeyBuilder.addCachingToKey(key, opts)
expect(newKey).to.equal(`${key}-converted-cache/style-thumbnail`)
})
it('should add format first, then style', function () {
const opts = {
style: 'thumbnail',
format: 'png',
}
const newKey = KeyBuilder.addCachingToKey(key, opts)
expect(newKey).to.equal(
`${key}-converted-cache/format-png-style-thumbnail`
)
})
})
})