2019-12-16 06:20:22 -05:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
2019-12-16 06:20:22 -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
|
|
|
|
2019-12-16 06:20:22 -05:00
|
|
|
describe("LocalFileWriter", function() {
|
2014-02-14 11:39:05 -05:00
|
|
|
|
2019-12-16 06:20:22 -05:00
|
|
|
beforeEach(function() {
|
2014-02-14 11:39:05 -05:00
|
|
|
|
2019-12-16 06:20:22 -05:00
|
|
|
this.keyBuilder = SandboxedModule.require(modulePath, { requires: {
|
|
|
|
"logger-sharelatex": {
|
|
|
|
log() {},
|
|
|
|
err() {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
return this.key = "123/456";
|
|
|
|
});
|
2014-02-14 11:39:05 -05:00
|
|
|
|
2019-12-16 06:20:22 -05:00
|
|
|
return describe("cachedKey", function() {
|
2014-02-14 11:39:05 -05:00
|
|
|
|
2019-12-16 06:20:22 -05:00
|
|
|
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
|
|
|
|
2019-12-16 06:20:22 -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
|
|
|
|
2019-12-16 06:20:22 -05:00
|
|
|
return it("should add format on first", function() {
|
|
|
|
const opts = {
|
|
|
|
style: "thumbnail",
|
2014-02-14 11:39:05 -05:00
|
|
|
format: "png"
|
2019-12-16 06:20:22 -05:00
|
|
|
};
|
|
|
|
const newKey = this.keyBuilder.addCachingToKey(this.key, opts);
|
|
|
|
return newKey.should.equal(`${this.key}-converted-cache/format-png-style-thumbnail`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|