From b6991f5ff90ae35a882f31844f607b276081d85c Mon Sep 17 00:00:00 2001 From: decaffeinate Date: Tue, 25 Feb 2020 17:03:37 +0100 Subject: [PATCH] decaffeinate: Convert SmokeTests.coffee to JS --- services/clsi/test/smoke/coffee/SmokeTests.js | 76 ++++++++++++------- 1 file changed, 48 insertions(+), 28 deletions(-) diff --git a/services/clsi/test/smoke/coffee/SmokeTests.js b/services/clsi/test/smoke/coffee/SmokeTests.js index 9ecf09c17b..a8ad80b5d2 100644 --- a/services/clsi/test/smoke/coffee/SmokeTests.js +++ b/services/clsi/test/smoke/coffee/SmokeTests.js @@ -1,22 +1,29 @@ -chai = require("chai") -chai.should() unless Object.prototype.should? -expect = chai.expect -request = require "request" -Settings = require "settings-sharelatex" +/* + * decaffeinate suggestions: + * DS101: Remove unnecessary use of Array.from + * DS102: Remove unnecessary code created because of implicit returns + * 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", -> - before (done) -> - request.post { - url: url - json: - compile: - resources: [ - path: "main.tex" - content: """ +describe("Running a compile", function() { + before(function(done) { + return request.post({ + url, + json: { + compile: { + resources: [{ + path: "main.tex", + content: `\ % Membrane-like surface % Author: Yotam Avital \\documentclass{article} @@ -47,18 +54,31 @@ describe "Running a compile", -> } } \\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", -> - for file in @body.compile.outputFiles - return if file.type == "pdf" - throw new Error("no pdf returned") + it("should return the pdf", function() { + for (let file of Array.from(this.body.compile.outputFiles)) { + if (file.type === "pdf") { return; } + } + throw new Error("no pdf returned"); + }); - it "should return the log", -> - for file in @body.compile.outputFiles - return if file.type == "log" - throw new Error("no log returned") + return it("should return the log", function() { + for (let file of Array.from(this.body.compile.outputFiles)) { + if (file.type === "log") { return; } + } + throw new Error("no log returned"); + }); +});