diff --git a/src/tests/backend/specs/api/characterEncoding.js b/src/tests/backend/specs/api/characterEncoding.js
index 00183e12a..b1348af3b 100644
--- a/src/tests/backend/specs/api/characterEncoding.js
+++ b/src/tests/backend/specs/api/characterEncoding.js
@@ -16,6 +16,8 @@ const apiKey = common.apiKey;
let apiVersion = 1;
const testPadId = makeid();
+const endPoint = (point, version) => `/api/${version || apiVersion}/${point}?apikey=${apiKey}`;
+
describe(__filename, function () {
describe('Connectivity For Character Encoding', function () {
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() {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
diff --git a/src/tests/backend/specs/api/chat.js b/src/tests/backend/specs/api/chat.js
index 570a8aaaa..7af81f1ed 100644
--- a/src/tests/backend/specs/api/chat.js
+++ b/src/tests/backend/specs/api/chat.js
@@ -1,3 +1,5 @@
+'use strict';
+
const common = require('../../common');
const settings = require('../../../../node/utils/Settings');
const supertest = require('supertest');
@@ -9,6 +11,8 @@ let authorID = '';
const padID = makeid();
const timestamp = Date.now();
+const endPoint = (point) => `/api/${apiVersion}/${point}?apikey=${apiKey}`;
+
describe(__filename, function () {
describe('API Versioning', function () {
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) {
api.get(endPoint('createAuthor'))
.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
})
.expect('Content-Type', /json/)
@@ -62,7 +68,8 @@ describe(__filename, function () {
describe('appendChatMessage', function () {
this.timeout(100);
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) => {
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) {
api.get(`${endPoint('getChatHistory')}&padID=${padID}`)
.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');
})
.expect('Content-Type', /json/)
@@ -100,10 +109,6 @@ describe(__filename, function () {
});
});
-var endPoint = function (point) {
- return `/api/${apiVersion}/${point}?apikey=${apiKey}`;
-};
-
function makeid() {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
diff --git a/src/tests/backend/specs/api/importexport.js b/src/tests/backend/specs/api/importexport.js
index 960f019bd..dd07e6e3a 100644
--- a/src/tests/backend/specs/api/importexport.js
+++ b/src/tests/backend/specs/api/importexport.js
@@ -14,6 +14,8 @@ const api = supertest(`http://${settings.ip}:${settings.port}`);
const apiKey = common.apiKey;
const apiVersion = 1;
+const endPoint = (point, version) => `/api/${version || apiVersion}/${point}?apikey=${apiKey}`;
+
const testImports = {
'malformed': {
input: '
wtf',
@@ -306,12 +308,6 @@ describe(__filename, function () {
});
});
-
-function endPoint(point, version) {
- version = version || apiVersion;
- return `/api/${version}/${point}?apikey=${apiKey}`;
-}
-
function makeid() {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
diff --git a/src/tests/backend/specs/api/instance.js b/src/tests/backend/specs/api/instance.js
index ab465033e..c45f5acd2 100644
--- a/src/tests/backend/specs/api/instance.js
+++ b/src/tests/backend/specs/api/instance.js
@@ -1,3 +1,5 @@
+'use strict';
+
/*
* Tests for the instance-level APIs
*
@@ -12,6 +14,8 @@ const api = supertest(`http://${settings.ip}:${settings.port}`);
const apiKey = common.apiKey;
const apiVersion = '1.2.14';
+const endPoint = (point, version) => `/api/${version || apiVersion}/${point}?apikey=${apiKey}`;
+
describe(__filename, function () {
describe('Connectivity for instance-level API tests', function () {
it('can connect', function (done) {
@@ -29,16 +33,21 @@ describe(__filename, function () {
.expect((res) => {
if (res.body.code !== 0) throw new Error('getStats() failed');
- 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)}`);
+ 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)}`);
}
- if (!(('totalSessions' in 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 (!('totalSessions' in 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'))) {
- throw new Error(`Response to getStats() does not contain field totalActivePads, or it's not a number: ${JSON.stringify(res.body.data)}`);
+ if (!('totalActivePads' in 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/)
@@ -46,8 +55,3 @@ describe(__filename, function () {
});
});
});
-
-var endPoint = function (point, version) {
- version = version || apiVersion;
- return `/api/${version}/${point}?apikey=${apiKey}`;
-};
diff --git a/src/tests/backend/specs/api/pad.js b/src/tests/backend/specs/api/pad.js
index c94ad810d..2b06973f4 100644
--- a/src/tests/backend/specs/api/pad.js
+++ b/src/tests/backend/specs/api/pad.js
@@ -1,3 +1,5 @@
+'use strict';
+
/*
* ACHTUNG: there is a copied & modified version of this file in
* /src/tests/container/specs/api/pad.js
@@ -5,6 +7,7 @@
* TODO: unify those two files, and merge in a single one.
*/
+const assert = require('assert').strict;
const async = require('async');
const common = require('../../common');
const settings = require('../../../../node/utils/Settings');
@@ -18,6 +21,8 @@ const testPadId = makeid();
let lastEdited = '';
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
* verify it is exported back correctly
@@ -160,7 +165,9 @@ describe(__filename, function () {
api.get(`${endPoint('getSavedRevisionsCount')}&padID=${testPadId}`)
.expect((res) => {
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(200, done);
@@ -173,7 +180,7 @@ describe(__filename, function () {
api.get(`${endPoint('listSavedRevisions')}&padID=${testPadId}`)
.expect((res) => {
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(200, done);
@@ -326,7 +333,9 @@ describe(__filename, function () {
api.get(`${endPoint('getSavedRevisionsCount')}&padID=${testPadId}`)
.expect((res) => {
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(200, done);
@@ -339,7 +348,7 @@ describe(__filename, function () {
api.get(`${endPoint('listSavedRevisions')}&padID=${testPadId}`)
.expect((res) => {
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(200, done);
@@ -374,7 +383,9 @@ describe(__filename, function () {
this.timeout(150);
api.get(`${endPoint('listAuthorsOfPad')}&padID=${testPadId}`)
.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(200, done);
@@ -451,7 +462,6 @@ describe(__filename, function () {
});
});
- const originalPadId = testPadId;
const newPadId = makeid();
const copiedPadId = makeid();
@@ -609,7 +619,9 @@ describe(__filename, function () {
api.get(`${endPoint('getText')}&padID=${testPadId}`)
.expect((res) => {
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(200, done);
@@ -627,7 +639,9 @@ describe(__filename, function () {
html,
})
.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(200, done);
@@ -730,7 +744,8 @@ describe(__filename, function () {
describe('copyPad', function () {
it('copies the content of a existent pad', function (done) {
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) => {
if (res.body.code !== 0) throw new Error('Copy Pad Failed');
})
@@ -747,13 +762,14 @@ describe(__filename, function () {
createNewPadWithHtml(sourcePadId, ulHtml, done);
});
- beforeEach(function () {
+ beforeEach(async function () {
newPad = makeid();
});
it('returns a successful response', function (done) {
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) => {
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
it('creates a new pad with the same content as the source pad', function (done) {
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) => {
if (res.body.code !== 0) throw new Error('Copy Pad Without History Failed');
})
.end(() => {
api.get(`${endPoint('getHTML')}&padID=${newPad}`)
.expect((res) => {
- const receivedHtml = res.body.data.html.replace('