decaffeinate: Convert SmokeTests.coffee to JS

This commit is contained in:
decaffeinate
2020-02-25 17:03:37 +01:00
committed by mserranom
parent d1e0b8548e
commit 4f01b7716e

View File

@@ -1,22 +1,29 @@
chai = require("chai") /*
chai.should() unless Object.prototype.should? * decaffeinate suggestions:
expect = chai.expect * DS101: Remove unnecessary use of Array.from
request = require "request" * DS102: Remove unnecessary code created because of implicit returns
Settings = require "settings-sharelatex" * DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const chai = require("chai");
if (Object.prototype.should == null) { chai.should(); }
const { expect } = chai;
const request = require("request");
const Settings = require("settings-sharelatex");
buildUrl = (path) -> "http://#{Settings.internal.clsi.host}:#{Settings.internal.clsi.port}/#{path}" const buildUrl = path => `http://${Settings.internal.clsi.host}:${Settings.internal.clsi.port}/${path}`;
url = buildUrl("project/smoketest-#{process.pid}/compile") const url = buildUrl(`project/smoketest-${process.pid}/compile`);
describe "Running a compile", -> describe("Running a compile", function() {
before (done) -> before(function(done) {
request.post { return request.post({
url: url url,
json: json: {
compile: compile: {
resources: [ resources: [{
path: "main.tex" path: "main.tex",
content: """ content: `\
% Membrane-like surface % Membrane-like surface
% Author: Yotam Avital % Author: Yotam Avital
\\documentclass{article} \\documentclass{article}
@@ -47,18 +54,31 @@ describe "Running a compile", ->
} }
} }
\\end{tikzpicture} \\end{tikzpicture}
\\end{document} \\end{document}\
""" `
}
] ]
}, (@error, @response, @body) => }
done() }
}, (error, response, body) => {
this.error = error;
this.response = response;
this.body = body;
return done();
});
});
it "should return the pdf", -> it("should return the pdf", function() {
for file in @body.compile.outputFiles for (let file of Array.from(this.body.compile.outputFiles)) {
return if file.type == "pdf" if (file.type === "pdf") { return; }
throw new Error("no pdf returned") }
throw new Error("no pdf returned");
});
it "should return the log", -> return it("should return the log", function() {
for file in @body.compile.outputFiles for (let file of Array.from(this.body.compile.outputFiles)) {
return if file.type == "log" if (file.type === "log") { return; }
throw new Error("no log returned") }
throw new Error("no log returned");
});
});