lint: Run eslint --fix on bin/ and tests/

This commit is contained in:
Richard Hansen 2020-11-23 13:21:51 -05:00 committed by John McLear
parent 0625739cb8
commit b8d07a42eb
78 changed files with 4319 additions and 4599 deletions

View file

@ -7,23 +7,23 @@
*/
const common = require('../../common');
const supertest = require(__dirname + '/../../../../src/node_modules/supertest');
const settings = require(__dirname + '/../../../../src/node/utils/Settings');
const api = supertest('http://' + settings.ip + ':' + settings.port);
const supertest = require(`${__dirname}/../../../../src/node_modules/supertest`);
const settings = require(`${__dirname}/../../../../src/node/utils/Settings`);
const api = supertest(`http://${settings.ip}:${settings.port}`);
var 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;
var apiVersion = 1;
let apiVersion = 1;
var testPadId = makeid();
const testPadId = makeid();
describe(__filename, function() {
describe('API Versioning', function() {
it('errors if can not connect', function(done) {
describe(__filename, function () {
describe('API Versioning', function () {
it('errors if can not connect', function (done) {
api
.get('/api/')
.expect(function(res) {
.expect((res) => {
apiVersion = res.body.currentVersion;
if (!res.body.currentVersion) throw new Error('No version set in API');
return;
@ -32,12 +32,12 @@ describe(__filename, function() {
});
});
describe('OpenAPI definition', function() {
it('generates valid openapi definition document', function(done) {
describe('OpenAPI definition', function () {
it('generates valid openapi definition document', function (done) {
api
.get('/api/openapi.json')
.expect(function(res) {
const { valid, errors } = validateOpenAPI(res.body, 3);
.expect((res) => {
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}`);
@ -48,11 +48,11 @@ describe(__filename, function() {
});
});
describe('jsonp support', function() {
it('supports jsonp calls', function(done) {
describe('jsonp support', function () {
it('supports jsonp calls', function (done) {
api
.get(endPoint('createPad') + '&jsonp=jsonp_1&padID=' + testPadId)
.expect(function(res) {
.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
.expect((res) => {
if (!res.text.match('jsonp_1')) throw new Error('no jsonp call seen');
})
.expect('Content-Type', /javascript/)
@ -61,15 +61,15 @@ describe(__filename, function() {
});
});
var endPoint = function(point) {
return '/api/' + apiVersion + '/' + point + '?apikey=' + apiKey;
var endPoint = function (point) {
return `/api/${apiVersion}/${point}?apikey=${apiKey}`;
};
function makeid() {
var text = '';
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (var i = 0; i < 5; i++) {
for (let i = 0; i < 5; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;

View file

@ -5,86 +5,86 @@
*/
const common = require('../../common');
const supertest = require(__dirname+'/../../../../src/node_modules/supertest');
const supertest = require(`${__dirname}/../../../../src/node_modules/supertest`);
const fs = require('fs');
const settings = require(__dirname + '/../../../../src/node/utils/Settings');
const api = supertest('http://'+settings.ip+":"+settings.port);
const settings = require(`${__dirname}/../../../../src/node/utils/Settings`);
const api = supertest(`http://${settings.ip}:${settings.port}`);
const apiKey = common.apiKey;
var apiVersion = 1;
var testPadId = makeid();
let apiVersion = 1;
const testPadId = makeid();
describe(__filename, function() {
describe('Connectivity For Character Encoding', function() {
it('can connect', function(done) {
describe(__filename, function () {
describe('Connectivity For Character Encoding', function () {
it('can connect', function (done) {
api.get('/api/')
.expect('Content-Type', /json/)
.expect(200, done)
.expect(200, done);
});
})
});
describe('API Versioning', function() {
it('finds the version tag', function(done) {
describe('API Versioning', function () {
it('finds the version tag', function (done) {
api.get('/api/')
.expect(function(res){
.expect((res) => {
apiVersion = res.body.currentVersion;
if (!res.body.currentVersion) throw new Error("No version set in API");
if (!res.body.currentVersion) throw new Error('No version set in API');
return;
})
.expect(200, done)
.expect(200, done);
});
})
});
describe('Permission', function() {
it('errors with invalid APIKey', function(done) {
describe('Permission', function () {
it('errors with invalid APIKey', function (done) {
// This is broken because Etherpad doesn't handle HTTP codes properly see #2343
// If your APIKey is password you deserve to fail all tests anyway
var permErrorURL = '/api/'+apiVersion+'/createPad?apikey=password&padID=test';
const permErrorURL = `/api/${apiVersion}/createPad?apikey=password&padID=test`;
api.get(permErrorURL)
.expect(401, done)
.expect(401, done);
});
})
});
describe('createPad', function() {
it('creates a new Pad', function(done) {
api.get(endPoint('createPad')+"&padID="+testPadId)
.expect(function(res){
if(res.body.code !== 0) throw new Error("Unable to create new Pad");
describe('createPad', function () {
it('creates a new Pad', function (done) {
api.get(`${endPoint('createPad')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Unable to create new Pad');
})
.expect('Content-Type', /json/)
.expect(200, done)
.expect(200, done);
});
})
});
describe('setHTML', function() {
it('Sets the HTML of a Pad attempting to weird utf8 encoded content', function(done) {
fs.readFile('../tests/backend/specs/api/emojis.html', 'utf8', function(err, html) {
describe('setHTML', function () {
it('Sets the HTML of a Pad attempting to weird utf8 encoded content', function (done) {
fs.readFile('../tests/backend/specs/api/emojis.html', 'utf8', (err, html) => {
api.post(endPoint('setHTML'))
.send({
"padID": testPadId,
"html": html,
padID: testPadId,
html,
})
.expect(function(res){
if(res.body.code !== 0) throw new Error("Can't set HTML properly");
.expect((res) => {
if (res.body.code !== 0) throw new Error("Can't set HTML properly");
})
.expect('Content-Type', /json/)
.expect(200, done);
});
});
})
});
describe('getHTML', function() {
it('get the HTML of Pad with emojis', function(done) {
api.get(endPoint('getHTML')+"&padID="+testPadId)
.expect(function(res){
if (res.body.data.html.indexOf("&#127484") === -1) {
throw new Error("Unable to get the HTML");
describe('getHTML', function () {
it('get the HTML of Pad with emojis', function (done) {
api.get(`${endPoint('getHTML')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.data.html.indexOf('&#127484') === -1) {
throw new Error('Unable to get the HTML');
}
})
.expect('Content-Type', /json/)
.expect(200, done)
.expect(200, done);
});
})
});
});
/*
@ -93,16 +93,16 @@ describe(__filename, function() {
*/
var endPoint = function(point, version){
var endPoint = function (point, version) {
version = version || apiVersion;
return '/api/'+version+'/'+point+'?apikey='+apiKey;
}
return `/api/${version}/${point}?apikey=${apiKey}`;
};
function makeid() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for( var i=0; i < 10; i++ ){
for (let i = 0; i < 10; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;

View file

@ -1,4 +1,4 @@
function m(mod) { return __dirname + '/../../../../src/' + mod; }
function m(mod) { return `${__dirname}/../../../../src/${mod}`; }
const common = require('../../common');
const settings = require(m('node/utils/Settings'));
@ -6,27 +6,27 @@ const supertest = require(m('node_modules/supertest'));
const api = supertest(`http://${settings.ip}:${settings.port}`);
const apiKey = common.apiKey;
var apiVersion = 1;
var authorID = "";
var padID = makeid();
var timestamp = Date.now();
let apiVersion = 1;
let authorID = '';
const padID = makeid();
const timestamp = Date.now();
describe(__filename, function() {
describe('API Versioning', function(){
it('errors if can not connect', function(done) {
describe(__filename, function () {
describe('API Versioning', function () {
it('errors if can not connect', function (done) {
api.get('/api/')
.expect(function(res){
.expect((res) => {
apiVersion = res.body.currentVersion;
if (!res.body.currentVersion) throw new Error("No version set in API");
if (!res.body.currentVersion) throw new Error('No version set in API');
return;
})
.expect(200, done)
.expect(200, done);
});
})
});
// BEGIN GROUP AND AUTHOR TESTS
/////////////////////////////////////
/////////////////////////////////////
// ///////////////////////////////////
// ///////////////////////////////////
/* Tests performed
-> createPad(padID)
@ -36,76 +36,76 @@ describe(__filename, function() {
-> getChatHistory(padID)
*/
describe('createPad', function(){
it('creates a new Pad', function(done) {
api.get(endPoint('createPad')+"&padID="+padID)
.expect(function(res){
if(res.body.code !== 0) throw new Error("Unable to create new Pad");
describe('createPad', function () {
it('creates a new Pad', function (done) {
api.get(`${endPoint('createPad')}&padID=${padID}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Unable to create new Pad');
})
.expect('Content-Type', /json/)
.expect(200, done)
.expect(200, done);
});
})
});
describe('createAuthor', function(){
it('Creates an author with a name set', function(done) {
describe('createAuthor', function () {
it('Creates an author with a name set', function (done) {
api.get(endPoint('createAuthor'))
.expect(function(res){
if(res.body.code !== 0 || !res.body.data.authorID) throw new Error("Unable to create author");
.expect((res) => {
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/)
.expect(200, done)
.expect(200, done);
});
})
});
describe('appendChatMessage', function(){
it('Adds a chat message to the pad', function(done) {
api.get(endPoint('appendChatMessage')+"&padID="+padID+"&text=blalblalbha&authorID="+authorID+"&time="+timestamp)
.expect(function(res){
if(res.body.code !== 0) throw new Error("Unable to create chat message");
describe('appendChatMessage', function () {
it('Adds a chat message to the pad', function (done) {
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');
})
.expect('Content-Type', /json/)
.expect(200, done)
.expect(200, done);
});
})
});
describe('getChatHead', function(){
it('Gets the head of chat', function(done) {
api.get(endPoint('getChatHead')+"&padID="+padID)
.expect(function(res){
if(res.body.data.chatHead !== 0) throw new Error("Chat Head Length is wrong");
describe('getChatHead', function () {
it('Gets the head of chat', function (done) {
api.get(`${endPoint('getChatHead')}&padID=${padID}`)
.expect((res) => {
if (res.body.data.chatHead !== 0) throw new Error('Chat Head Length is wrong');
if(res.body.code !== 0) throw new Error("Unable to get chat head");
if (res.body.code !== 0) throw new Error('Unable to get chat head');
})
.expect('Content-Type', /json/)
.expect(200, done)
.expect(200, done);
});
})
});
describe('getChatHistory', function(){
it('Gets Chat History of a Pad', function(done) {
api.get(endPoint('getChatHistory')+"&padID="+padID)
.expect(function(res){
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");
describe('getChatHistory', 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.code !== 0) throw new Error('Unable to get chat history');
})
.expect('Content-Type', /json/)
.expect(200, done)
.expect(200, done);
});
})
});
});
var endPoint = function(point){
return '/api/'+apiVersion+'/'+point+'?apikey='+apiKey;
}
var endPoint = function (point) {
return `/api/${apiVersion}/${point}?apikey=${apiKey}`;
};
function makeid() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for( var i=0; i < 5; i++ ){
for (let i = 0; i < 5; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;

View file

@ -6,39 +6,39 @@
*/
const common = require('../../common');
const supertest = require(__dirname+'/../../../../src/node_modules/supertest');
const settings = require(__dirname+'/../../../../tests/container/loadSettings.js').loadSettings();
const api = supertest('http://'+settings.ip+":"+settings.port);
const supertest = require(`${__dirname}/../../../../src/node_modules/supertest`);
const settings = require(`${__dirname}/../../../../tests/container/loadSettings.js`).loadSettings();
const api = supertest(`http://${settings.ip}:${settings.port}`);
const apiKey = common.apiKey;
var apiVersion = 1;
var lastEdited = "";
const apiVersion = 1;
const lastEdited = '';
var testImports = {
"malformed": {
const testImports = {
'malformed': {
input: '<html><body><li>wtf</ul></body></html>',
expectedHTML: '<!DOCTYPE HTML><html><body>wtf<br><br></body></html>',
expectedText: 'wtf\n\n'
expectedText: 'wtf\n\n',
},
"nonelistiteminlist #3620":{
'nonelistiteminlist #3620': {
input: '<html><body><ul>test<li>FOO</li></ul></body></html>',
expectedHTML: '<!DOCTYPE HTML><html><body><ul class="bullet">test<li>FOO</ul><br></body></html>',
expectedText: '\ttest\n\t* FOO\n\n'
expectedText: '\ttest\n\t* FOO\n\n',
},
"whitespaceinlist #3620":{
'whitespaceinlist #3620': {
input: '<html><body><ul> <li>FOO</li></ul></body></html>',
expectedHTML: '<!DOCTYPE HTML><html><body><ul class="bullet"><li>FOO</ul><br></body></html>',
expectedText: '\t* FOO\n\n'
expectedText: '\t* FOO\n\n',
},
"prefixcorrectlinenumber":{
'prefixcorrectlinenumber': {
input: '<html><body><ol><li>should be 1</li><li>should be 2</li></ol></body></html>',
expectedHTML: '<!DOCTYPE HTML><html><body><ol start="1" class="number"><li>should be 1</li><li>should be 2</ol><br></body></html>',
expectedText: '\t1. should be 1\n\t2. should be 2\n\n'
expectedText: '\t1. should be 1\n\t2. should be 2\n\n',
},
"prefixcorrectlinenumbernested":{
'prefixcorrectlinenumbernested': {
input: '<html><body><ol><li>should be 1</li><ol><li>foo</li></ol><li>should be 2</li></ol></body></html>',
expectedHTML: '<!DOCTYPE HTML><html><body><ol start="1" class="number"><li>should be 1<ol start="2" class="number"><li>foo</ol><li>should be 2</ol><br></body></html>',
expectedText: '\t1. should be 1\n\t\t1.1. foo\n\t2. should be 2\n\n'
expectedText: '\t1. should be 1\n\t\t1.1. foo\n\t2. should be 2\n\n',
},
/*
@ -54,39 +54,39 @@ var testImports = {
expectedText: '\t1. should be 1\n\ttest\n\t2. should be 2\n\n'
}
*/
}
};
describe(__filename, function() {
Object.keys(testImports).forEach(function(testName) {
var testPadId = makeid();
describe(__filename, function () {
Object.keys(testImports).forEach((testName) => {
const testPadId = makeid();
test = testImports[testName];
describe('createPad', function() {
it('creates a new Pad', function(done) {
api.get(endPoint('createPad') + "&padID=" + testPadId)
.expect(function(res) {
if(res.body.code !== 0) throw new Error("Unable to create new Pad");
describe('createPad', function () {
it('creates a new Pad', function (done) {
api.get(`${endPoint('createPad')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Unable to create new Pad');
})
.expect('Content-Type', /json/)
.expect(200, done)
.expect(200, done);
});
})
});
describe('setHTML', function() {
it('Sets the HTML', function(done) {
api.get(endPoint('setHTML') + "&padID=" + testPadId + "&html=" + test.input)
.expect(function(res) {
if(res.body.code !== 0) throw new Error("Error:" + testName)
describe('setHTML', function () {
it('Sets the HTML', function (done) {
api.get(`${endPoint('setHTML')}&padID=${testPadId}&html=${test.input}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error(`Error:${testName}`);
})
.expect('Content-Type', /json/)
.expect(200, done)
.expect(200, done);
});
})
});
describe('getHTML', function() {
it('Gets back the HTML of a Pad', function(done) {
api.get(endPoint('getHTML') + "&padID=" + testPadId)
.expect(function(res) {
var receivedHtml = res.body.data.html;
describe('getHTML', function () {
it('Gets back the HTML of a Pad', function (done) {
api.get(`${endPoint('getHTML')}&padID=${testPadId}`)
.expect((res) => {
const receivedHtml = res.body.data.html;
if (receivedHtml !== test.expectedHTML) {
throw new Error(`HTML received from export is not the one we were expecting.
Test Name:
@ -103,15 +103,15 @@ describe(__filename, function() {
}
})
.expect('Content-Type', /json/)
.expect(200, done)
.expect(200, done);
});
})
});
describe('getText', function() {
it('Gets back the Text of a Pad', function(done) {
api.get(endPoint('getText') + "&padID=" + testPadId)
.expect(function(res) {
var receivedText = res.body.data.text;
describe('getText', function () {
it('Gets back the Text of a Pad', function (done) {
api.get(`${endPoint('getText')}&padID=${testPadId}`)
.expect((res) => {
const receivedText = res.body.data.text;
if (receivedText !== test.expectedText) {
throw new Error(`Text received from export is not the one we were expecting.
Test Name:
@ -128,33 +128,33 @@ describe(__filename, function() {
}
})
.expect('Content-Type', /json/)
.expect(200, done)
.expect(200, done);
});
})
});
});
});
var endPoint = function(point, version){
var endPoint = function (point, version) {
version = version || apiVersion;
return '/api/'+version+'/'+point+'?apikey='+apiKey;
}
return `/api/${version}/${point}?apikey=${apiKey}`;
};
function makeid() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for( var i=0; i < 5; i++ ){
for (let i = 0; i < 5; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
function generateLongText(){
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
function generateLongText() {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for( var i=0; i < 80000; i++ ){
for (let i = 0; i < 80000; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
@ -162,22 +162,19 @@ function generateLongText(){
// 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 (var 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;
}
// 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;
}
}
return true;
};

View file

@ -6,38 +6,38 @@
const assert = require('assert').strict;
const common = require('../../common');
const superagent = require(__dirname+'/../../../../src/node_modules/superagent');
const superagent = require(`${__dirname}/../../../../src/node_modules/superagent`);
const fs = require('fs');
const settings = require(__dirname+'/../../../../src/node/utils/Settings');
const padManager = require(__dirname+'/../../../../src/node/db/PadManager');
const plugins = require(__dirname+'/../../../../src/static/js/pluginfw/plugin_defs');
const settings = require(`${__dirname}/../../../../src/node/utils/Settings`);
const padManager = require(`${__dirname}/../../../../src/node/db/PadManager`);
const plugins = require(`${__dirname}/../../../../src/static/js/pluginfw/plugin_defs`);
const padText = fs.readFileSync("../tests/backend/specs/api/test.txt");
const etherpadDoc = fs.readFileSync("../tests/backend/specs/api/test.etherpad");
const wordDoc = fs.readFileSync("../tests/backend/specs/api/test.doc");
const wordXDoc = fs.readFileSync("../tests/backend/specs/api/test.docx");
const odtDoc = fs.readFileSync("../tests/backend/specs/api/test.odt");
const pdfDoc = fs.readFileSync("../tests/backend/specs/api/test.pdf");
const padText = fs.readFileSync('../tests/backend/specs/api/test.txt');
const etherpadDoc = fs.readFileSync('../tests/backend/specs/api/test.etherpad');
const wordDoc = fs.readFileSync('../tests/backend/specs/api/test.doc');
const wordXDoc = fs.readFileSync('../tests/backend/specs/api/test.docx');
const odtDoc = fs.readFileSync('../tests/backend/specs/api/test.odt');
const pdfDoc = fs.readFileSync('../tests/backend/specs/api/test.pdf');
let agent;
const apiKey = common.apiKey;
var apiVersion = 1;
const apiVersion = 1;
const testPadId = makeid();
const testPadIdEnc = encodeURIComponent(testPadId);
describe(__filename, function() {
before(async function() { agent = await common.init(); });
describe(__filename, function () {
before(async function () { agent = await common.init(); });
describe('Connectivity', function(){
it('can connect', async function() {
describe('Connectivity', function () {
it('can connect', async function () {
await agent.get('/api/')
.expect(200)
.expect('Content-Type', /json/);
});
});
describe('API Versioning', function(){
it('finds the version tag', async function() {
describe('API Versioning', function () {
it('finds the version tag', async function () {
await agent.get('/api/')
.expect(200)
.expect((res) => assert(res.body.currentVersion));
@ -70,10 +70,10 @@ describe(__filename, function() {
curl -s -v --form file=@/home/jose/test.txt http://127.0.0.1:9001/p/foo/import
*/
describe('Imports and Exports', function(){
describe('Imports and Exports', function () {
const backups = {};
beforeEach(async function() {
beforeEach(async function () {
backups.hooks = {};
for (const hookName of ['preAuthorize', 'authenticate', 'authorize']) {
backups.hooks[hookName] = plugins.hooks[hookName];
@ -86,43 +86,43 @@ describe(__filename, function() {
settings.users = {user: {password: 'user-password'}};
});
afterEach(async function() {
afterEach(async function () {
Object.assign(plugins.hooks, backups.hooks);
// Note: This does not unset settings that were added.
Object.assign(settings, backups.settings);
});
it('creates a new Pad, imports content to it, checks that content', async function() {
await agent.get(endPoint('createPad') + `&padID=${testPadId}`)
it('creates a new Pad, imports content to it, checks that content', async function () {
await agent.get(`${endPoint('createPad')}&padID=${testPadId}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => assert.equal(res.body.code, 0));
await agent.post(`/p/${testPadId}/import`)
.attach('file', padText, {filename: '/test.txt', contentType: 'text/plain'})
.expect(200);
await agent.get(endPoint('getText') + `&padID=${testPadId}`)
await agent.get(`${endPoint('getText')}&padID=${testPadId}`)
.expect(200)
.expect((res) => assert.equal(res.body.data.text, padText.toString()));
});
it('gets read only pad Id and exports the html and text for this pad', async function(){
let ro = await agent.get(endPoint('getReadOnlyID')+"&padID="+testPadId)
it('gets read only pad Id and exports the html and text for this pad', async function () {
const ro = await agent.get(`${endPoint('getReadOnlyID')}&padID=${testPadId}`)
.expect(200)
.expect((res) => assert.ok(JSON.parse(res.text).data.readOnlyID));
let readOnlyId = JSON.parse(ro.text).data.readOnlyID;
const readOnlyId = JSON.parse(ro.text).data.readOnlyID;
await agent.get(`/p/${readOnlyId}/export/html`)
.expect(200)
.expect((res) => assert(res.text.indexOf("This is the") !== -1));
.expect((res) => assert(res.text.indexOf('This is the') !== -1));
await agent.get(`/p/${readOnlyId}/export/txt`)
.expect(200)
.expect((res) => assert(res.text.indexOf("This is the") !== -1));
.expect((res) => assert(res.text.indexOf('This is the') !== -1));
});
describe('Import/Export tests requiring AbiWord/LibreOffice', function() {
before(function() {
describe('Import/Export tests requiring AbiWord/LibreOffice', function () {
before(function () {
if ((!settings.abiword || settings.abiword.indexOf('/') === -1) &&
(!settings.soffice || settings.soffice.indexOf('/') === -1)) {
this.skip();
@ -131,21 +131,21 @@ describe(__filename, function() {
// For some reason word import does not work in testing..
// TODO: fix support for .doc files..
it('Tries to import .doc that uses soffice or abiword', async function() {
it('Tries to import .doc that uses soffice or abiword', async function () {
await agent.post(`/p/${testPadId}/import`)
.attach('file', wordDoc, {filename: '/test.doc', contentType: 'application/msword'})
.expect(200)
.expect(/FrameCall\('undefined', 'ok'\);/);
});
it('exports DOC', async function() {
it('exports DOC', async function () {
await agent.get(`/p/${testPadId}/export/doc`)
.buffer(true).parse(superagent.parse['application/octet-stream'])
.expect(200)
.expect((res) => assert(res.body.length >= 9000));
});
it('Tries to import .docx that uses soffice or abiword', async function() {
it('Tries to import .docx that uses soffice or abiword', async function () {
await agent.post(`/p/${testPadId}/import`)
.attach('file', wordXDoc, {
filename: '/test.docx',
@ -155,44 +155,43 @@ describe(__filename, function() {
.expect(/FrameCall\('undefined', 'ok'\);/);
});
it('exports DOC from imported DOCX', async function() {
it('exports DOC from imported DOCX', async function () {
await agent.get(`/p/${testPadId}/export/doc`)
.buffer(true).parse(superagent.parse['application/octet-stream'])
.expect(200)
.expect((res) => assert(res.body.length >= 9100));
});
it('Tries to import .pdf that uses soffice or abiword', async function() {
it('Tries to import .pdf that uses soffice or abiword', async function () {
await agent.post(`/p/${testPadId}/import`)
.attach('file', pdfDoc, {filename: '/test.pdf', contentType: 'application/pdf'})
.expect(200)
.expect(/FrameCall\('undefined', 'ok'\);/);
});
it('exports PDF', async function() {
it('exports PDF', async function () {
await agent.get(`/p/${testPadId}/export/pdf`)
.buffer(true).parse(superagent.parse['application/octet-stream'])
.expect(200)
.expect((res) => assert(res.body.length >= 1000));
});
it('Tries to import .odt that uses soffice or abiword', async function() {
it('Tries to import .odt that uses soffice or abiword', async function () {
await agent.post(`/p/${testPadId}/import`)
.attach('file', odtDoc, {filename: '/test.odt', contentType: 'application/odt'})
.expect(200)
.expect(/FrameCall\('undefined', 'ok'\);/);
});
it('exports ODT', async function() {
it('exports ODT', async function () {
await agent.get(`/p/${testPadId}/export/odt`)
.buffer(true).parse(superagent.parse['application/octet-stream'])
.expect(200)
.expect((res) => assert(res.body.length >= 7000));
});
}); // End of AbiWord/LibreOffice tests.
it('Tries to import .etherpad', async function() {
it('Tries to import .etherpad', async function () {
await agent.post(`/p/${testPadId}/import`)
.attach('file', etherpadDoc, {
filename: '/test.etherpad',
@ -202,21 +201,21 @@ describe(__filename, function() {
.expect(/FrameCall\('true', 'ok'\);/);
});
it('exports Etherpad', async function() {
it('exports Etherpad', async function () {
await agent.get(`/p/${testPadId}/export/etherpad`)
.buffer(true).parse(superagent.parse.text)
.expect(200)
.expect(/hello/);
});
it('exports HTML for this Etherpad file', async function() {
it('exports HTML for this Etherpad file', async function () {
await agent.get(`/p/${testPadId}/export/html`)
.expect(200)
.expect('content-type', 'text/html; charset=utf-8')
.expect(/<ul class="bullet"><li><ul class="bullet"><li>hello<\/ul><\/li><\/ul>/);
});
it('Tries to import unsupported file type', async function() {
it('Tries to import unsupported file type', async function () {
settings.allowUnknownFileEnds = false;
await agent.post(`/p/${testPadId}/import`)
.attach('file', padText, {filename: '/test.xasdasdxx', contentType: 'weirdness/jobby'})
@ -224,7 +223,7 @@ describe(__filename, function() {
.expect((res) => assert.doesNotMatch(res.text, /FrameCall\('undefined', 'ok'\);/));
});
describe('Import authorization checks', function() {
describe('Import authorization checks', function () {
let authorize;
const deleteTestPad = async () => {
@ -240,18 +239,18 @@ describe(__filename, function() {
return pad;
};
beforeEach(async function() {
beforeEach(async function () {
await deleteTestPad();
settings.requireAuthorization = true;
authorize = () => true;
plugins.hooks.authorize = [{hook_fn: (hookName, {req}, cb) => cb([authorize(req)])}];
});
afterEach(async function() {
afterEach(async function () {
await deleteTestPad();
});
it('!authn !exist -> create', async function() {
it('!authn !exist -> create', async function () {
await agent.post(`/p/${testPadIdEnc}/import`)
.attach('file', padText, {filename: '/test.txt', contentType: 'text/plain'})
.expect(200);
@ -260,7 +259,7 @@ describe(__filename, function() {
assert.equal(pad.text(), padText.toString());
});
it('!authn exist -> replace', async function() {
it('!authn exist -> replace', async function () {
const pad = await createTestPad('before import');
await agent.post(`/p/${testPadIdEnc}/import`)
.attach('file', padText, {filename: '/test.txt', contentType: 'text/plain'})
@ -269,7 +268,7 @@ describe(__filename, function() {
assert.equal(pad.text(), padText.toString());
});
it('authn anonymous !exist -> fail', async function() {
it('authn anonymous !exist -> fail', async function () {
settings.requireAuthentication = true;
await agent.post(`/p/${testPadIdEnc}/import`)
.attach('file', padText, {filename: '/test.txt', contentType: 'text/plain'})
@ -277,7 +276,7 @@ describe(__filename, function() {
assert(!(await padManager.doesPadExist(testPadId)));
});
it('authn anonymous exist -> fail', async function() {
it('authn anonymous exist -> fail', async function () {
settings.requireAuthentication = true;
const pad = await createTestPad('before import\n');
await agent.post(`/p/${testPadIdEnc}/import`)
@ -286,7 +285,7 @@ describe(__filename, function() {
assert.equal(pad.text(), 'before import\n');
});
it('authn user create !exist -> create', async function() {
it('authn user create !exist -> create', async function () {
settings.requireAuthentication = true;
await agent.post(`/p/${testPadIdEnc}/import`)
.auth('user', 'user-password')
@ -297,7 +296,7 @@ describe(__filename, function() {
assert.equal(pad.text(), padText.toString());
});
it('authn user modify !exist -> fail', async function() {
it('authn user modify !exist -> fail', async function () {
settings.requireAuthentication = true;
authorize = () => 'modify';
await agent.post(`/p/${testPadIdEnc}/import`)
@ -307,7 +306,7 @@ describe(__filename, function() {
assert(!(await padManager.doesPadExist(testPadId)));
});
it('authn user readonly !exist -> fail', async function() {
it('authn user readonly !exist -> fail', async function () {
settings.requireAuthentication = true;
authorize = () => 'readOnly';
await agent.post(`/p/${testPadIdEnc}/import`)
@ -317,7 +316,7 @@ describe(__filename, function() {
assert(!(await padManager.doesPadExist(testPadId)));
});
it('authn user create exist -> replace', async function() {
it('authn user create exist -> replace', async function () {
settings.requireAuthentication = true;
const pad = await createTestPad('before import\n');
await agent.post(`/p/${testPadIdEnc}/import`)
@ -327,7 +326,7 @@ describe(__filename, function() {
assert.equal(pad.text(), padText.toString());
});
it('authn user modify exist -> replace', async function() {
it('authn user modify exist -> replace', async function () {
settings.requireAuthentication = true;
authorize = () => 'modify';
const pad = await createTestPad('before import\n');
@ -338,7 +337,7 @@ describe(__filename, function() {
assert.equal(pad.text(), padText.toString());
});
it('authn user readonly exist -> fail', async function() {
it('authn user readonly exist -> fail', async function () {
const pad = await createTestPad('before import\n');
settings.requireAuthentication = true;
authorize = () => 'readOnly';
@ -353,19 +352,16 @@ describe(__filename, function() {
}); // End of tests.
var endPoint = function(point, version){
var endPoint = function (point, version) {
version = version || apiVersion;
return `/api/${version}/${point}?apikey=${apiKey}`;
};
function makeid() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for( var i=0; i < 5; i++ ){
for (let i = 0; i < 5; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;

View file

@ -4,27 +4,27 @@
* Section "GLOBAL FUNCTIONS" in src/node/db/API.js
*/
const common = require('../../common');
const supertest = require(__dirname+'/../../../../src/node_modules/supertest');
const settings = require(__dirname+'/../../../../src/node/utils/Settings');
const api = supertest('http://'+settings.ip+":"+settings.port);
const supertest = require(`${__dirname}/../../../../src/node_modules/supertest`);
const settings = require(`${__dirname}/../../../../src/node/utils/Settings`);
const api = supertest(`http://${settings.ip}:${settings.port}`);
const apiKey = common.apiKey;
var apiVersion = '1.2.14';
const apiVersion = '1.2.14';
describe(__filename, function() {
describe('Connectivity for instance-level API tests', function() {
it('can connect', function(done) {
describe(__filename, function () {
describe('Connectivity for instance-level API tests', function () {
it('can connect', function (done) {
api.get('/api/')
.expect('Content-Type', /json/)
.expect(200, done)
.expect(200, done);
});
});
describe('getStats', function() {
it('Gets the stats of a running instance', function(done) {
describe('getStats', function () {
it('Gets the stats of a running instance', function (done) {
api.get(endPoint('getStats'))
.expect(function(res) {
if (res.body.code !== 0) throw new Error("getStats() failed");
.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)}`);
@ -44,7 +44,7 @@ describe(__filename, function() {
});
});
var endPoint = function(point, version){
var endPoint = function (point, version) {
version = version || apiVersion;
return '/api/'+version+'/'+point+'?apikey='+apiKey;
}
return `/api/${version}/${point}?apikey=${apiKey}`;
};

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
const assert = require('assert').strict;
const common = require('../../common');
const supertest = require(__dirname + '/../../../../src/node_modules/supertest');
const settings = require(__dirname + '/../../../../src/node/utils/Settings');
const supertest = require(`${__dirname}/../../../../src/node_modules/supertest`);
const settings = require(`${__dirname}/../../../../src/node/utils/Settings`);
const api = supertest(`http://${settings.ip}:${settings.port}`);
const apiKey = common.apiKey;
@ -11,9 +11,9 @@ let authorID = '';
let sessionID = '';
let padID = makeid();
describe(__filename, function() {
describe('API Versioning', function() {
it('errors if can not connect', async function() {
describe(__filename, function () {
describe('API Versioning', function () {
it('errors if can not connect', async function () {
await api.get('/api/')
.expect(200)
.expect((res) => {
@ -24,8 +24,8 @@ describe(__filename, function() {
});
// BEGIN GROUP AND AUTHOR TESTS
/////////////////////////////////////
/////////////////////////////////////
// ///////////////////////////////////
// ///////////////////////////////////
/* Tests performed
-> createGroup() -- should return a groupID
@ -53,8 +53,8 @@ describe(__filename, function() {
-> listPadsOfAuthor(authorID)
*/
describe('API: Group creation and deletion', function() {
it('createGroup', async function() {
describe('API: Group creation and deletion', function () {
it('createGroup', async function () {
await api.get(endPoint('createGroup'))
.expect(200)
.expect('Content-Type', /json/)
@ -65,8 +65,8 @@ describe(__filename, function() {
});
});
it('listSessionsOfGroup for empty group', async function() {
await api.get(endPoint('listSessionsOfGroup') + `&groupID=${groupID}`)
it('listSessionsOfGroup for empty group', async function () {
await api.get(`${endPoint('listSessionsOfGroup')}&groupID=${groupID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -75,8 +75,8 @@ describe(__filename, function() {
});
});
it('deleteGroup', async function() {
await api.get(endPoint('deleteGroup') + `&groupID=${groupID}`)
it('deleteGroup', async function () {
await api.get(`${endPoint('deleteGroup')}&groupID=${groupID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -84,8 +84,8 @@ describe(__filename, function() {
});
});
it('createGroupIfNotExistsFor', async function() {
await api.get(endPoint('createGroupIfNotExistsFor') + '&groupMapper=management')
it('createGroupIfNotExistsFor', async function () {
await api.get(`${endPoint('createGroupIfNotExistsFor')}&groupMapper=management`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -95,8 +95,8 @@ describe(__filename, function() {
});
});
describe('API: Author creation', function() {
it('createGroup', async function() {
describe('API: Author creation', function () {
it('createGroup', async function () {
await api.get(endPoint('createGroup'))
.expect(200)
.expect('Content-Type', /json/)
@ -107,7 +107,7 @@ describe(__filename, function() {
});
});
it('createAuthor', async function() {
it('createAuthor', async function () {
await api.get(endPoint('createAuthor'))
.expect(200)
.expect('Content-Type', /json/)
@ -117,8 +117,8 @@ describe(__filename, function() {
});
});
it('createAuthor with name', async function() {
await api.get(endPoint('createAuthor') + '&name=john')
it('createAuthor with name', async function () {
await api.get(`${endPoint('createAuthor')}&name=john`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -128,8 +128,8 @@ describe(__filename, function() {
});
});
it('createAuthorIfNotExistsFor', async function() {
await api.get(endPoint('createAuthorIfNotExistsFor') + '&authorMapper=chris')
it('createAuthorIfNotExistsFor', async function () {
await api.get(`${endPoint('createAuthorIfNotExistsFor')}&authorMapper=chris`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -138,8 +138,8 @@ describe(__filename, function() {
});
});
it('getAuthorName', async function() {
await api.get(endPoint('getAuthorName') + `&authorID=${authorID}`)
it('getAuthorName', async function () {
await api.get(`${endPoint('getAuthorName')}&authorID=${authorID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -149,10 +149,10 @@ describe(__filename, function() {
});
});
describe('API: Sessions', function() {
it('createSession', async function() {
await api.get(endPoint('createSession') +
`&authorID=${authorID}&groupID=${groupID}&validUntil=999999999999`)
describe('API: Sessions', function () {
it('createSession', async function () {
await api.get(`${endPoint('createSession')
}&authorID=${authorID}&groupID=${groupID}&validUntil=999999999999`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -162,8 +162,8 @@ describe(__filename, function() {
});
});
it('getSessionInfo', async function() {
await api.get(endPoint('getSessionInfo') + `&sessionID=${sessionID}`)
it('getSessionInfo', async function () {
await api.get(`${endPoint('getSessionInfo')}&sessionID=${sessionID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -174,8 +174,8 @@ describe(__filename, function() {
});
});
it('listSessionsOfGroup', async function() {
await api.get(endPoint('listSessionsOfGroup') + `&groupID=${groupID}`)
it('listSessionsOfGroup', async function () {
await api.get(`${endPoint('listSessionsOfGroup')}&groupID=${groupID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -184,8 +184,8 @@ describe(__filename, function() {
});
});
it('deleteSession', async function() {
await api.get(endPoint('deleteSession') + `&sessionID=${sessionID}`)
it('deleteSession', async function () {
await api.get(`${endPoint('deleteSession')}&sessionID=${sessionID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -193,8 +193,8 @@ describe(__filename, function() {
});
});
it('getSessionInfo of deleted session', async function() {
await api.get(endPoint('getSessionInfo') + `&sessionID=${sessionID}`)
it('getSessionInfo of deleted session', async function () {
await api.get(`${endPoint('getSessionInfo')}&sessionID=${sessionID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -203,9 +203,9 @@ describe(__filename, function() {
});
});
describe('API: Group pad management', function() {
it('listPads', async function() {
await api.get(endPoint('listPads') + `&groupID=${groupID}`)
describe('API: Group pad management', function () {
it('listPads', async function () {
await api.get(`${endPoint('listPads')}&groupID=${groupID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -214,8 +214,8 @@ describe(__filename, function() {
});
});
it('createGroupPad', async function() {
await api.get(endPoint('createGroupPad') + `&groupID=${groupID}&padName=${padID}`)
it('createGroupPad', async function () {
await api.get(`${endPoint('createGroupPad')}&groupID=${groupID}&padName=${padID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -224,8 +224,8 @@ describe(__filename, function() {
});
});
it('listPads after creating a group pad', async function() {
await api.get(endPoint('listPads') + `&groupID=${groupID}`)
it('listPads after creating a group pad', async function () {
await api.get(`${endPoint('listPads')}&groupID=${groupID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -235,9 +235,9 @@ describe(__filename, function() {
});
});
describe('API: Pad security', function() {
it('getPublicStatus', async function() {
await api.get(endPoint('getPublicStatus') + `&padID=${padID}`)
describe('API: Pad security', function () {
it('getPublicStatus', async function () {
await api.get(`${endPoint('getPublicStatus')}&padID=${padID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -246,8 +246,8 @@ describe(__filename, function() {
});
});
it('setPublicStatus', async function() {
await api.get(endPoint('setPublicStatus') + `&padID=${padID}&publicStatus=true`)
it('setPublicStatus', async function () {
await api.get(`${endPoint('setPublicStatus')}&padID=${padID}&publicStatus=true`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -255,8 +255,8 @@ describe(__filename, function() {
});
});
it('getPublicStatus after changing public status', async function() {
await api.get(endPoint('getPublicStatus') + `&padID=${padID}`)
it('getPublicStatus after changing public status', async function () {
await api.get(`${endPoint('getPublicStatus')}&padID=${padID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -267,12 +267,12 @@ describe(__filename, function() {
});
// NOT SURE HOW TO POPULAT THIS /-_-\
///////////////////////////////////////
///////////////////////////////////////
// /////////////////////////////////////
// /////////////////////////////////////
describe('API: Misc', function() {
it('listPadsOfAuthor', async function() {
await api.get(endPoint('listPadsOfAuthor') + `&authorID=${authorID}`)
describe('API: Misc', function () {
it('listPadsOfAuthor', async function () {
await api.get(`${endPoint('listPadsOfAuthor')}&authorID=${authorID}`)
.expect(200)
.expect('Content-Type', /json/)
.expect((res) => {
@ -284,8 +284,7 @@ describe(__filename, function() {
});
const endPoint = function(point) {
const endPoint = function (point) {
return `/api/${apiVersion}/${point}?apikey=${apiKey}`;
};

View file

@ -1,21 +1,21 @@
var assert = require('assert')
os = require('os'),
fs = require('fs'),
path = require('path'),
TidyHtml = null,
Settings = null;
const assert = require('assert');
os = require('os'),
fs = require('fs'),
path = require('path'),
TidyHtml = null,
Settings = null;
var npm = require("../../../../src/node_modules/npm/lib/npm.js");
var nodeify = require('../../../../src/node_modules/nodeify');
const npm = require('../../../../src/node_modules/npm/lib/npm.js');
const nodeify = require('../../../../src/node_modules/nodeify');
describe(__filename, function() {
describe('tidyHtml', function() {
before(function(done) {
npm.load({}, function(err) {
describe(__filename, function () {
describe('tidyHtml', function () {
before(function (done) {
npm.load({}, (err) => {
assert.ok(!err);
TidyHtml = require('../../../../src/node/utils/TidyHtml');
Settings = require('../../../../src/node/utils/Settings');
return done()
return done();
});
});
@ -23,7 +23,7 @@ describe(__filename, function() {
return nodeify(TidyHtml.tidy(file), callback);
}
it('Tidies HTML', function(done) {
it('Tidies HTML', function (done) {
// If the user hasn't configured Tidy, we skip this tests as it's required for this test
if (!Settings.tidyHtml) {
this.skip();
@ -32,15 +32,15 @@ describe(__filename, function() {
// Try to tidy up a bad HTML file
const tmpDir = os.tmpdir();
var tmpFile = path.join(tmpDir, 'tmp_' + (Math.floor(Math.random() * 1000000)) + '.html')
const tmpFile = path.join(tmpDir, `tmp_${Math.floor(Math.random() * 1000000)}.html`);
fs.writeFileSync(tmpFile, '<html><body><p>a paragraph</p><li>List without outer UL</li>trailing closing p</p></body></html>');
tidy(tmpFile, function(err){
tidy(tmpFile, (err) => {
assert.ok(!err);
// Read the file again
var cleanedHtml = fs.readFileSync(tmpFile).toString();
const cleanedHtml = fs.readFileSync(tmpFile).toString();
var expectedHtml = [
const expectedHtml = [
'<title></title>',
'</head>',
'<body>',
@ -57,13 +57,13 @@ describe(__filename, function() {
});
});
it('can deal with errors', function(done) {
it('can deal with errors', function (done) {
// If the user hasn't configured Tidy, we skip this tests as it's required for this test
if (!Settings.tidyHtml) {
this.skip();
}
tidy('/some/none/existing/file.html', function(err) {
tidy('/some/none/existing/file.html', (err) => {
assert.ok(err);
return done();
});