lint: `src/tests/backend/specs/api/api.js`

pull/4766/head
Richard Hansen 2021-02-13 00:42:20 -05:00
parent eb9d5bb470
commit 66544be354
2 changed files with 17 additions and 15 deletions

View File

@ -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",

View File

@ -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;
}