mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
lint: Fix ESLint errors in backend tests
This commit is contained in:
parent
00d45e3229
commit
3d2f77f75d
7 changed files with 79 additions and 78 deletions
|
@ -16,6 +16,8 @@ const apiKey = common.apiKey;
|
||||||
let apiVersion = 1;
|
let apiVersion = 1;
|
||||||
const testPadId = makeid();
|
const testPadId = makeid();
|
||||||
|
|
||||||
|
const endPoint = (point, version) => `/api/${version || apiVersion}/${point}?apikey=${apiKey}`;
|
||||||
|
|
||||||
describe(__filename, function () {
|
describe(__filename, function () {
|
||||||
describe('Connectivity For Character Encoding', function () {
|
describe('Connectivity For Character Encoding', function () {
|
||||||
it('can connect', function (done) {
|
it('can connect', function (done) {
|
||||||
|
@ -101,11 +103,6 @@ describe(__filename, function () {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var endPoint = function (point, version) {
|
|
||||||
version = version || apiVersion;
|
|
||||||
return `/api/${version}/${point}?apikey=${apiKey}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
function makeid() {
|
function makeid() {
|
||||||
let text = '';
|
let text = '';
|
||||||
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const common = require('../../common');
|
const common = require('../../common');
|
||||||
const settings = require('../../../../node/utils/Settings');
|
const settings = require('../../../../node/utils/Settings');
|
||||||
const supertest = require('supertest');
|
const supertest = require('supertest');
|
||||||
|
@ -9,6 +11,8 @@ let authorID = '';
|
||||||
const padID = makeid();
|
const padID = makeid();
|
||||||
const timestamp = Date.now();
|
const timestamp = Date.now();
|
||||||
|
|
||||||
|
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) {
|
||||||
|
@ -51,7 +55,9 @@ describe(__filename, function () {
|
||||||
it('Creates an author with a name set', function (done) {
|
it('Creates an author with a name set', function (done) {
|
||||||
api.get(endPoint('createAuthor'))
|
api.get(endPoint('createAuthor'))
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.code !== 0 || !res.body.data.authorID) throw new Error('Unable to create author');
|
if (res.body.code !== 0 || !res.body.data.authorID) {
|
||||||
|
throw new Error('Unable to create author');
|
||||||
|
}
|
||||||
authorID = res.body.data.authorID; // we will be this author for the rest of the tests
|
authorID = res.body.data.authorID; // we will be this author for the rest of the tests
|
||||||
})
|
})
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
|
@ -62,7 +68,8 @@ describe(__filename, function () {
|
||||||
describe('appendChatMessage', function () {
|
describe('appendChatMessage', function () {
|
||||||
this.timeout(100);
|
this.timeout(100);
|
||||||
it('Adds a chat message to the pad', function (done) {
|
it('Adds a chat message to the pad', function (done) {
|
||||||
api.get(`${endPoint('appendChatMessage')}&padID=${padID}&text=blalblalbha&authorID=${authorID}&time=${timestamp}`)
|
api.get(`${endPoint('appendChatMessage')}&padID=${padID}&text=blalblalbha` +
|
||||||
|
`&authorID=${authorID}&time=${timestamp}`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.code !== 0) throw new Error('Unable to create chat message');
|
if (res.body.code !== 0) throw new Error('Unable to create chat message');
|
||||||
})
|
})
|
||||||
|
@ -91,7 +98,9 @@ describe(__filename, function () {
|
||||||
it('Gets Chat History of a Pad', function (done) {
|
it('Gets Chat History of a Pad', function (done) {
|
||||||
api.get(`${endPoint('getChatHistory')}&padID=${padID}`)
|
api.get(`${endPoint('getChatHistory')}&padID=${padID}`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.data.messages.length !== 1) throw new Error('Chat History Length is wrong');
|
if (res.body.data.messages.length !== 1) {
|
||||||
|
throw new Error('Chat History Length is wrong');
|
||||||
|
}
|
||||||
if (res.body.code !== 0) throw new Error('Unable to get chat history');
|
if (res.body.code !== 0) throw new Error('Unable to get chat history');
|
||||||
})
|
})
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
|
@ -100,10 +109,6 @@ describe(__filename, function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var endPoint = function (point) {
|
|
||||||
return `/api/${apiVersion}/${point}?apikey=${apiKey}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
function makeid() {
|
function makeid() {
|
||||||
let text = '';
|
let text = '';
|
||||||
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
|
|
@ -14,6 +14,8 @@ const api = supertest(`http://${settings.ip}:${settings.port}`);
|
||||||
const apiKey = common.apiKey;
|
const apiKey = common.apiKey;
|
||||||
const apiVersion = 1;
|
const apiVersion = 1;
|
||||||
|
|
||||||
|
const endPoint = (point, version) => `/api/${version || apiVersion}/${point}?apikey=${apiKey}`;
|
||||||
|
|
||||||
const testImports = {
|
const testImports = {
|
||||||
'malformed': {
|
'malformed': {
|
||||||
input: '<html><body><li>wtf</ul></body></html>',
|
input: '<html><body><li>wtf</ul></body></html>',
|
||||||
|
@ -306,12 +308,6 @@ describe(__filename, function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function endPoint(point, version) {
|
|
||||||
version = version || apiVersion;
|
|
||||||
return `/api/${version}/${point}?apikey=${apiKey}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeid() {
|
function makeid() {
|
||||||
let text = '';
|
let text = '';
|
||||||
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tests for the instance-level APIs
|
* Tests for the instance-level APIs
|
||||||
*
|
*
|
||||||
|
@ -12,6 +14,8 @@ const api = supertest(`http://${settings.ip}:${settings.port}`);
|
||||||
const apiKey = common.apiKey;
|
const apiKey = common.apiKey;
|
||||||
const apiVersion = '1.2.14';
|
const apiVersion = '1.2.14';
|
||||||
|
|
||||||
|
const endPoint = (point, version) => `/api/${version || apiVersion}/${point}?apikey=${apiKey}`;
|
||||||
|
|
||||||
describe(__filename, function () {
|
describe(__filename, function () {
|
||||||
describe('Connectivity for instance-level API tests', function () {
|
describe('Connectivity for instance-level API tests', function () {
|
||||||
it('can connect', function (done) {
|
it('can connect', function (done) {
|
||||||
|
@ -29,16 +33,21 @@ describe(__filename, function () {
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.code !== 0) throw new Error('getStats() failed');
|
if (res.body.code !== 0) throw new Error('getStats() failed');
|
||||||
|
|
||||||
if (!(('totalPads' in res.body.data) && (typeof res.body.data.totalPads === 'number'))) {
|
if (!('totalPads' in res.body.data && typeof res.body.data.totalPads === 'number')) {
|
||||||
throw new Error(`Response to getStats() does not contain field totalPads, or it's not a number: ${JSON.stringify(res.body.data)}`);
|
throw new Error('Response to getStats() does not contain field totalPads, or ' +
|
||||||
|
`it's not a number: ${JSON.stringify(res.body.data)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(('totalSessions' in res.body.data) && (typeof res.body.data.totalSessions === 'number'))) {
|
if (!('totalSessions' in res.body.data &&
|
||||||
throw new Error(`Response to getStats() does not contain field totalSessions, or it's not a number: ${JSON.stringify(res.body.data)}`);
|
typeof res.body.data.totalSessions === 'number')) {
|
||||||
|
throw new Error('Response to getStats() does not contain field totalSessions, or ' +
|
||||||
|
`it's not a number: ${JSON.stringify(res.body.data)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(('totalActivePads' in res.body.data) && (typeof res.body.data.totalActivePads === 'number'))) {
|
if (!('totalActivePads' in res.body.data &&
|
||||||
throw new Error(`Response to getStats() does not contain field totalActivePads, or it's not a number: ${JSON.stringify(res.body.data)}`);
|
typeof res.body.data.totalActivePads === 'number')) {
|
||||||
|
throw new Error('Response to getStats() does not contain field totalActivePads, or ' +
|
||||||
|
`it's not a number: ${JSON.stringify(res.body.data)}`);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
|
@ -46,8 +55,3 @@ describe(__filename, function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var endPoint = function (point, version) {
|
|
||||||
version = version || apiVersion;
|
|
||||||
return `/api/${version}/${point}?apikey=${apiKey}`;
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ACHTUNG: there is a copied & modified version of this file in
|
* ACHTUNG: there is a copied & modified version of this file in
|
||||||
* <basedir>/src/tests/container/specs/api/pad.js
|
* <basedir>/src/tests/container/specs/api/pad.js
|
||||||
|
@ -5,6 +7,7 @@
|
||||||
* TODO: unify those two files, and merge in a single one.
|
* TODO: unify those two files, and merge in a single one.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const assert = require('assert').strict;
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const common = require('../../common');
|
const common = require('../../common');
|
||||||
const settings = require('../../../../node/utils/Settings');
|
const settings = require('../../../../node/utils/Settings');
|
||||||
|
@ -18,6 +21,8 @@ const testPadId = makeid();
|
||||||
let lastEdited = '';
|
let lastEdited = '';
|
||||||
const text = generateLongText();
|
const text = generateLongText();
|
||||||
|
|
||||||
|
const endPoint = (point, version) => `/api/${version || apiVersion}/${point}?apikey=${apiKey}`;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Html document with nested lists of different types, to test its import and
|
* Html document with nested lists of different types, to test its import and
|
||||||
* verify it is exported back correctly
|
* verify it is exported back correctly
|
||||||
|
@ -160,7 +165,9 @@ describe(__filename, function () {
|
||||||
api.get(`${endPoint('getSavedRevisionsCount')}&padID=${testPadId}`)
|
api.get(`${endPoint('getSavedRevisionsCount')}&padID=${testPadId}`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.code !== 0) throw new Error('Unable to get Saved Revisions Count');
|
if (res.body.code !== 0) throw new Error('Unable to get Saved Revisions Count');
|
||||||
if (res.body.data.savedRevisions !== 0) throw new Error('Incorrect Saved Revisions Count');
|
if (res.body.data.savedRevisions !== 0) {
|
||||||
|
throw new Error('Incorrect Saved Revisions Count');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
|
@ -173,7 +180,7 @@ describe(__filename, function () {
|
||||||
api.get(`${endPoint('listSavedRevisions')}&padID=${testPadId}`)
|
api.get(`${endPoint('listSavedRevisions')}&padID=${testPadId}`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.code !== 0) throw new Error('Unable to get Saved Revisions List');
|
if (res.body.code !== 0) throw new Error('Unable to get Saved Revisions List');
|
||||||
if (!res.body.data.savedRevisions.equals([])) throw new Error('Incorrect Saved Revisions List');
|
assert.deepEqual(res.body.data.savedRevisions, []);
|
||||||
})
|
})
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
|
@ -326,7 +333,9 @@ describe(__filename, function () {
|
||||||
api.get(`${endPoint('getSavedRevisionsCount')}&padID=${testPadId}`)
|
api.get(`${endPoint('getSavedRevisionsCount')}&padID=${testPadId}`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.code !== 0) throw new Error('Unable to get Saved Revisions Count');
|
if (res.body.code !== 0) throw new Error('Unable to get Saved Revisions Count');
|
||||||
if (res.body.data.savedRevisions !== 1) throw new Error('Incorrect Saved Revisions Count');
|
if (res.body.data.savedRevisions !== 1) {
|
||||||
|
throw new Error('Incorrect Saved Revisions Count');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
|
@ -339,7 +348,7 @@ describe(__filename, function () {
|
||||||
api.get(`${endPoint('listSavedRevisions')}&padID=${testPadId}`)
|
api.get(`${endPoint('listSavedRevisions')}&padID=${testPadId}`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.code !== 0) throw new Error('Unable to get Saved Revisions List');
|
if (res.body.code !== 0) throw new Error('Unable to get Saved Revisions List');
|
||||||
if (!res.body.data.savedRevisions.equals([1])) throw new Error('Incorrect Saved Revisions List');
|
assert.deepEqual(res.body.data.savedRevisions, [1]);
|
||||||
})
|
})
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
|
@ -374,7 +383,9 @@ describe(__filename, function () {
|
||||||
this.timeout(150);
|
this.timeout(150);
|
||||||
api.get(`${endPoint('listAuthorsOfPad')}&padID=${testPadId}`)
|
api.get(`${endPoint('listAuthorsOfPad')}&padID=${testPadId}`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.data.authorIDs.length !== 0) throw new Error('# of Authors of pad is not 0');
|
if (res.body.data.authorIDs.length !== 0) {
|
||||||
|
throw new Error('# of Authors of pad is not 0');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
|
@ -451,7 +462,6 @@ describe(__filename, function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const originalPadId = testPadId;
|
|
||||||
const newPadId = makeid();
|
const newPadId = makeid();
|
||||||
const copiedPadId = makeid();
|
const copiedPadId = makeid();
|
||||||
|
|
||||||
|
@ -609,7 +619,9 @@ describe(__filename, function () {
|
||||||
api.get(`${endPoint('getText')}&padID=${testPadId}`)
|
api.get(`${endPoint('getText')}&padID=${testPadId}`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.code !== 0) throw new Error('Pad Get Text failed');
|
if (res.body.code !== 0) throw new Error('Pad Get Text failed');
|
||||||
if (res.body.data.text !== `${text}hello\n`) throw new Error('Pad Text not set properly');
|
if (res.body.data.text !== `${text}hello\n`) {
|
||||||
|
throw new Error('Pad Text not set properly');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
|
@ -627,7 +639,9 @@ describe(__filename, function () {
|
||||||
html,
|
html,
|
||||||
})
|
})
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.code !== 0) throw new Error("Crappy HTML Can't be Imported[we weren't able to sanitize it']");
|
if (res.body.code !== 0) {
|
||||||
|
throw new Error("Crappy HTML Can't be Imported[we weren't able to sanitize it']");
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
|
@ -730,7 +744,8 @@ describe(__filename, function () {
|
||||||
describe('copyPad', function () {
|
describe('copyPad', function () {
|
||||||
it('copies the content of a existent pad', function (done) {
|
it('copies the content of a existent pad', function (done) {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
api.get(`${endPoint('copyPad')}&sourceID=${testPadId}&destinationID=${copiedPadId}&force=true`)
|
api.get(`${endPoint('copyPad')}&sourceID=${testPadId}&destinationID=${copiedPadId}` +
|
||||||
|
'&force=true')
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.code !== 0) throw new Error('Copy Pad Failed');
|
if (res.body.code !== 0) throw new Error('Copy Pad Failed');
|
||||||
})
|
})
|
||||||
|
@ -747,13 +762,14 @@ describe(__filename, function () {
|
||||||
createNewPadWithHtml(sourcePadId, ulHtml, done);
|
createNewPadWithHtml(sourcePadId, ulHtml, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(async function () {
|
||||||
newPad = makeid();
|
newPad = makeid();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns a successful response', function (done) {
|
it('returns a successful response', function (done) {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}&destinationID=${newPad}&force=false`)
|
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}` +
|
||||||
|
`&destinationID=${newPad}&force=false`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.code !== 0) throw new Error('Copy Pad Without History Failed');
|
if (res.body.code !== 0) throw new Error('Copy Pad Without History Failed');
|
||||||
})
|
})
|
||||||
|
@ -764,14 +780,16 @@ describe(__filename, function () {
|
||||||
// this test validates if the source pad's text and attributes are kept
|
// this test validates if the source pad's text and attributes are kept
|
||||||
it('creates a new pad with the same content as the source pad', function (done) {
|
it('creates a new pad with the same content as the source pad', function (done) {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}&destinationID=${newPad}&force=false`)
|
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}` +
|
||||||
|
`&destinationID=${newPad}&force=false`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (res.body.code !== 0) throw new Error('Copy Pad Without History Failed');
|
if (res.body.code !== 0) throw new Error('Copy Pad Without History Failed');
|
||||||
})
|
})
|
||||||
.end(() => {
|
.end(() => {
|
||||||
api.get(`${endPoint('getHTML')}&padID=${newPad}`)
|
api.get(`${endPoint('getHTML')}&padID=${newPad}`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
const receivedHtml = res.body.data.html.replace('<br><br></body>', '</body>').toLowerCase();
|
const receivedHtml =
|
||||||
|
res.body.data.html.replace('<br><br></body>', '</body>').toLowerCase();
|
||||||
|
|
||||||
if (receivedHtml !== expectedHtml) {
|
if (receivedHtml !== expectedHtml) {
|
||||||
throw new Error(`HTML received from export is not the one we were expecting.
|
throw new Error(`HTML received from export is not the one we were expecting.
|
||||||
|
@ -794,7 +812,8 @@ describe(__filename, function () {
|
||||||
const padWithNonExistentGroup = `notExistentGroup$${padId}`;
|
const padWithNonExistentGroup = `notExistentGroup$${padId}`;
|
||||||
it('throws an error', function (done) {
|
it('throws an error', function (done) {
|
||||||
this.timeout(150);
|
this.timeout(150);
|
||||||
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}&destinationID=${padWithNonExistentGroup}&force=true`)
|
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}&` +
|
||||||
|
`destinationID=${padWithNonExistentGroup}&force=true`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
// code 1, it means an error has happened
|
// code 1, it means an error has happened
|
||||||
if (res.body.code !== 1) throw new Error('It should report an error');
|
if (res.body.code !== 1) throw new Error('It should report an error');
|
||||||
|
@ -813,7 +832,8 @@ describe(__filename, function () {
|
||||||
context('and force is false', function () {
|
context('and force is false', function () {
|
||||||
it('throws an error', function (done) {
|
it('throws an error', function (done) {
|
||||||
this.timeout(150);
|
this.timeout(150);
|
||||||
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}&destinationID=${padIdExistent}&force=false`)
|
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}` +
|
||||||
|
`&destinationID=${padIdExistent}&force=false`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
// code 1, it means an error has happened
|
// code 1, it means an error has happened
|
||||||
if (res.body.code !== 1) throw new Error('It should report an error');
|
if (res.body.code !== 1) throw new Error('It should report an error');
|
||||||
|
@ -825,10 +845,13 @@ describe(__filename, function () {
|
||||||
context('and force is true', function () {
|
context('and force is true', function () {
|
||||||
it('returns a successful response', function (done) {
|
it('returns a successful response', function (done) {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}&destinationID=${padIdExistent}&force=true`)
|
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}` +
|
||||||
|
`&destinationID=${padIdExistent}&force=true`)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
// code 1, it means an error has happened
|
// code 1, it means an error has happened
|
||||||
if (res.body.code !== 0) throw new Error('Copy pad without history with force true failed');
|
if (res.body.code !== 0) {
|
||||||
|
throw new Error('Copy pad without history with force true failed');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
});
|
});
|
||||||
|
@ -842,7 +865,7 @@ describe(__filename, function () {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var createNewPadWithHtml = function (padId, html, cb) {
|
const createNewPadWithHtml = (padId, html, cb) => {
|
||||||
api.get(`${endPoint('createPad')}&padID=${padId}`)
|
api.get(`${endPoint('createPad')}&padID=${padId}`)
|
||||||
.end(() => {
|
.end(() => {
|
||||||
api.post(endPoint('setHTML'))
|
api.post(endPoint('setHTML'))
|
||||||
|
@ -854,11 +877,6 @@ var createNewPadWithHtml = function (padId, html, cb) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var endPoint = function (point, version) {
|
|
||||||
version = version || apiVersion;
|
|
||||||
return `/api/${version}/${point}?apikey=${apiKey}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
function makeid() {
|
function makeid() {
|
||||||
let text = '';
|
let text = '';
|
||||||
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
@ -878,22 +896,3 @@ function generateLongText() {
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need this to compare arrays (listSavedRevisions test)
|
|
||||||
Array.prototype.equals = function (array) {
|
|
||||||
// if the other array is a falsy value, return
|
|
||||||
if (!array) return false;
|
|
||||||
// compare lengths - can save a lot of time
|
|
||||||
if (this.length != array.length) return false;
|
|
||||||
for (let i = 0, l = this.length; i < l; i++) {
|
|
||||||
// Check if we have nested arrays
|
|
||||||
if (this[i] instanceof Array && array[i] instanceof Array) {
|
|
||||||
// recurse into the nested arrays
|
|
||||||
if (!this[i].equals(array[i])) return false;
|
|
||||||
} else if (this[i] != array[i]) {
|
|
||||||
// Warning - two different object instances will never be equal: {x:20} != {x:20}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const assert = require('assert').strict;
|
const assert = require('assert').strict;
|
||||||
const common = require('../../common');
|
const common = require('../../common');
|
||||||
const settings = require('../../../../node/utils/Settings');
|
const settings = require('../../../../node/utils/Settings');
|
||||||
|
@ -12,6 +14,8 @@ let authorID = '';
|
||||||
let sessionID = '';
|
let sessionID = '';
|
||||||
let padID = makeid();
|
let padID = 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', async function () {
|
it('errors if can not connect', async function () {
|
||||||
|
@ -389,11 +393,6 @@ describe(__filename, function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const endPoint = function (point) {
|
|
||||||
return `/api/${apiVersion}/${point}?apikey=${apiKey}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
function makeid() {
|
function makeid() {
|
||||||
let text = '';
|
let text = '';
|
||||||
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* caching_middleware is responsible for serving everything under path `/javascripts/`
|
* caching_middleware is responsible for serving everything under path `/javascripts/`
|
||||||
* That includes packages as defined in `src/node/utils/tar.json` and probably also plugin code
|
* That includes packages as defined in `src/node/utils/tar.json` and probably also plugin code
|
||||||
|
@ -6,7 +8,6 @@
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert').strict;
|
const assert = require('assert').strict;
|
||||||
const url = require('url');
|
|
||||||
const queryString = require('querystring');
|
const queryString = require('querystring');
|
||||||
const settings = require('../../../node/utils/Settings');
|
const settings = require('../../../node/utils/Settings');
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ let agent;
|
||||||
*/
|
*/
|
||||||
function isPlaintextResponse(fileContent, resource) {
|
function isPlaintextResponse(fileContent, resource) {
|
||||||
// callback=require.define&v=1234
|
// callback=require.define&v=1234
|
||||||
const query = url.parse(resource).query;
|
const query = (new URL(resource, 'http://localhost')).search.slice(1);
|
||||||
// require.define
|
// require.define
|
||||||
const jsonp = queryString.parse(query).callback;
|
const jsonp = queryString.parse(query).callback;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue