From 66544be35410d010ed4398fe1166ec50c8c99975 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 13 Feb 2021 00:42:20 -0500 Subject: [PATCH] lint: `src/tests/backend/specs/api/api.js` --- src/package.json | 1 + src/tests/backend/specs/api/api.js | 31 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/package.json b/src/package.json index fca557978..215d7e809 100644 --- a/src/package.json +++ b/src/package.json @@ -88,6 +88,7 @@ "etherpad-cli-client": "0.0.9", "mocha": "7.1.2", "mocha-froth": "^0.2.10", + "openapi-schema-validation": "^0.4.2", "set-cookie-parser": "^2.4.6", "sinon": "^9.2.0", "superagent": "^3.8.3", diff --git a/src/tests/backend/specs/api/api.js b/src/tests/backend/specs/api/api.js index 359bb3f6a..54ba61cd2 100644 --- a/src/tests/backend/specs/api/api.js +++ b/src/tests/backend/specs/api/api.js @@ -1,3 +1,5 @@ +'use strict'; + /** * API specs * @@ -15,8 +17,20 @@ const api = supertest(`http://${settings.ip}:${settings.port}`); const apiKey = common.apiKey; let apiVersion = 1; +const makeid = () => { + let text = ''; + const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + + for (let i = 0; i < 5; i++) { + text += possible.charAt(Math.floor(Math.random() * possible.length)); + } + return text; +}; + const testPadId = makeid(); +const endPoint = (point) => `/api/${apiVersion}/${point}?apikey=${apiKey}`; + describe(__filename, function () { describe('API Versioning', function () { it('errors if can not connect', function (done) { @@ -39,7 +53,8 @@ describe(__filename, function () { const {valid, errors} = validateOpenAPI(res.body, 3); if (!valid) { const prettyErrors = JSON.stringify(errors, null, 2); - throw new Error(`Document is not valid OpenAPI. ${errors.length} validation errors:\n${prettyErrors}`); + throw new Error(`Document is not valid OpenAPI. ${errors.length} ` + + `validation errors:\n${prettyErrors}`); } return; }) @@ -59,17 +74,3 @@ describe(__filename, function () { }); }); }); - -var endPoint = function (point) { - return `/api/${apiVersion}/${point}?apikey=${apiKey}`; -}; - -function makeid() { - let text = ''; - const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - - for (let i = 0; i < 5; i++) { - text += possible.charAt(Math.floor(Math.random() * possible.length)); - } - return text; -}