mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 08:26:16 -04:00
lint: src/tests/backend/specs/api/api.js
This commit is contained in:
parent
eb9d5bb470
commit
66544be354
2 changed files with 17 additions and 15 deletions
|
@ -88,6 +88,7 @@
|
||||||
"etherpad-cli-client": "0.0.9",
|
"etherpad-cli-client": "0.0.9",
|
||||||
"mocha": "7.1.2",
|
"mocha": "7.1.2",
|
||||||
"mocha-froth": "^0.2.10",
|
"mocha-froth": "^0.2.10",
|
||||||
|
"openapi-schema-validation": "^0.4.2",
|
||||||
"set-cookie-parser": "^2.4.6",
|
"set-cookie-parser": "^2.4.6",
|
||||||
"sinon": "^9.2.0",
|
"sinon": "^9.2.0",
|
||||||
"superagent": "^3.8.3",
|
"superagent": "^3.8.3",
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API specs
|
* API specs
|
||||||
*
|
*
|
||||||
|
@ -15,8 +17,20 @@ const api = supertest(`http://${settings.ip}:${settings.port}`);
|
||||||
const apiKey = common.apiKey;
|
const apiKey = common.apiKey;
|
||||||
let apiVersion = 1;
|
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 testPadId = makeid();
|
||||||
|
|
||||||
|
const endPoint = (point) => `/api/${apiVersion}/${point}?apikey=${apiKey}`;
|
||||||
|
|
||||||
describe(__filename, function () {
|
describe(__filename, function () {
|
||||||
describe('API Versioning', function () {
|
describe('API Versioning', function () {
|
||||||
it('errors if can not connect', function (done) {
|
it('errors if can not connect', function (done) {
|
||||||
|
@ -39,7 +53,8 @@ describe(__filename, function () {
|
||||||
const {valid, errors} = validateOpenAPI(res.body, 3);
|
const {valid, errors} = validateOpenAPI(res.body, 3);
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
const prettyErrors = JSON.stringify(errors, null, 2);
|
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;
|
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;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue