mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 00:16:15 -04:00
api.js lint and timeouts
This commit is contained in:
parent
ff71e41812
commit
103e3398ad
1 changed files with 9 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
'use strict';
|
||||||
/**
|
/**
|
||||||
* API specs
|
* API specs
|
||||||
*
|
*
|
||||||
|
@ -11,7 +12,8 @@ const supertest = require(`${__dirname}/../../../../src/node_modules/supertest`)
|
||||||
const settings = require(`${__dirname}/../../../../src/node/utils/Settings`);
|
const settings = require(`${__dirname}/../../../../src/node/utils/Settings`);
|
||||||
const api = supertest(`http://${settings.ip}:${settings.port}`);
|
const api = supertest(`http://${settings.ip}:${settings.port}`);
|
||||||
|
|
||||||
const validateOpenAPI = require(`${__dirname}/../../../../src/node_modules/openapi-schema-validation`).validate;
|
const validateOpenAPI =
|
||||||
|
require(`${__dirname}/../../../../src/node_modules/openapi-schema-validation`).validate;
|
||||||
|
|
||||||
const apiKey = common.apiKey;
|
const apiKey = common.apiKey;
|
||||||
let apiVersion = 1;
|
let apiVersion = 1;
|
||||||
|
@ -21,6 +23,7 @@ const testPadId = makeid();
|
||||||
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) {
|
||||||
|
this.timeout(150);
|
||||||
api
|
api
|
||||||
.get('/api/')
|
.get('/api/')
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
|
@ -34,13 +37,15 @@ describe(__filename, function () {
|
||||||
|
|
||||||
describe('OpenAPI definition', function () {
|
describe('OpenAPI definition', function () {
|
||||||
it('generates valid openapi definition document', function (done) {
|
it('generates valid openapi definition document', function (done) {
|
||||||
|
this.timeout(150);
|
||||||
api
|
api
|
||||||
.get('/api/openapi.json')
|
.get('/api/openapi.json')
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
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;
|
||||||
})
|
})
|
||||||
|
@ -50,6 +55,7 @@ describe(__filename, function () {
|
||||||
|
|
||||||
describe('jsonp support', function () {
|
describe('jsonp support', function () {
|
||||||
it('supports jsonp calls', function (done) {
|
it('supports jsonp calls', function (done) {
|
||||||
|
this.timeout(150);
|
||||||
api
|
api
|
||||||
.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
|
.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
|
@ -61,9 +67,7 @@ describe(__filename, function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var endPoint = function (point) {
|
const endPoint = (point) => `/api/${apiVersion}/${point}?apikey=${apiKey}`;
|
||||||
return `/api/${apiVersion}/${point}?apikey=${apiKey}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
function makeid() {
|
function makeid() {
|
||||||
let text = '';
|
let text = '';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue