overleaf/services/filestore/test/unit/js/KeybuilderTests.js

59 lines
1.7 KiB
JavaScript
Raw Normal View History

/* eslint-disable
no-return-assign,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
2014-02-14 11:39:05 -05:00
const { assert } = require('chai')
const sinon = require('sinon')
const chai = require('chai')
const should = chai.should()
const { expect } = chai
const modulePath = '../../../app/js/KeyBuilder.js'
const SandboxedModule = require('sandboxed-module')
2014-02-14 11:39:05 -05:00
describe('LocalFileWriter', function() {
beforeEach(function() {
this.keyBuilder = SandboxedModule.require(modulePath, {
requires: {
'logger-sharelatex': {
log() {},
err() {}
}
}
})
return (this.key = '123/456')
})
2014-02-14 11:39:05 -05:00
return describe('cachedKey', function() {
it('should add the fomat on', function() {
const opts = { format: 'png' }
const newKey = this.keyBuilder.addCachingToKey(this.key, opts)
return newKey.should.equal(`${this.key}-converted-cache/format-png`)
})
2014-02-14 11:39:05 -05:00
it('should add the style on', function() {
const opts = { style: 'thumbnail' }
const newKey = this.keyBuilder.addCachingToKey(this.key, opts)
return newKey.should.equal(`${this.key}-converted-cache/style-thumbnail`)
})
2014-02-14 11:39:05 -05:00
return it('should add format on first', function() {
const opts = {
style: 'thumbnail',
format: 'png'
}
const newKey = this.keyBuilder.addCachingToKey(this.key, opts)
return newKey.should.equal(
`${this.key}-converted-cache/format-png-style-thumbnail`
)
})
})
})