mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
tests: Include the filename in the test output
Also some minor consistency cleanups.
This commit is contained in:
parent
50e402193b
commit
3e14016214
13 changed files with 2296 additions and 2276 deletions
|
@ -18,6 +18,7 @@ var apiVersion = 1;
|
||||||
|
|
||||||
var testPadId = makeid();
|
var testPadId = makeid();
|
||||||
|
|
||||||
|
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) {
|
||||||
api
|
api
|
||||||
|
@ -58,6 +59,7 @@ describe('jsonp support', function() {
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var endPoint = function(point) {
|
var endPoint = function(point) {
|
||||||
return '/api/' + apiVersion + '/' + point + '?apikey=' + apiKey;
|
return '/api/' + apiVersion + '/' + point + '?apikey=' + apiKey;
|
||||||
|
|
|
@ -14,6 +14,7 @@ const apiKey = common.apiKey;
|
||||||
var apiVersion = 1;
|
var apiVersion = 1;
|
||||||
var testPadId = makeid();
|
var testPadId = makeid();
|
||||||
|
|
||||||
|
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) {
|
||||||
api.get('/api/')
|
api.get('/api/')
|
||||||
|
@ -84,6 +85,7 @@ describe('getHTML', function(){
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ var authorID = "";
|
||||||
var padID = makeid();
|
var padID = makeid();
|
||||||
var timestamp = Date.now();
|
var timestamp = Date.now();
|
||||||
|
|
||||||
|
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) {
|
||||||
api.get('/api/')
|
api.get('/api/')
|
||||||
|
@ -94,6 +95,7 @@ describe('getChatHistory', function(){
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
});
|
||||||
|
|
||||||
var endPoint = function(point){
|
var endPoint = function(point){
|
||||||
return '/api/'+apiVersion+'/'+point+'?apikey='+apiKey;
|
return '/api/'+apiVersion+'/'+point+'?apikey='+apiKey;
|
||||||
|
|
|
@ -56,6 +56,7 @@ var testImports = {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
describe(__filename, function() {
|
||||||
Object.keys(testImports).forEach(function(testName) {
|
Object.keys(testImports).forEach(function(testName) {
|
||||||
var testPadId = makeid();
|
var testPadId = makeid();
|
||||||
test = testImports[testName];
|
test = testImports[testName];
|
||||||
|
@ -131,6 +132,7 @@ Object.keys(testImports).forEach(function (testName) {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
var endPoint = function(point, version){
|
var endPoint = function(point, version){
|
||||||
|
|
|
@ -23,6 +23,7 @@ var apiVersion = 1;
|
||||||
const testPadId = makeid();
|
const testPadId = makeid();
|
||||||
const testPadIdEnc = encodeURIComponent(testPadId);
|
const testPadIdEnc = encodeURIComponent(testPadId);
|
||||||
|
|
||||||
|
describe(__filename, function() {
|
||||||
before(async function() { agent = await common.init(); });
|
before(async function() { agent = await common.init(); });
|
||||||
|
|
||||||
describe('Connectivity', function(){
|
describe('Connectivity', function(){
|
||||||
|
@ -342,7 +343,7 @@ describe('Imports and Exports', function(){
|
||||||
assert.equal(pad.text(), 'before import\n');
|
assert.equal(pad.text(), 'before import\n');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}); // End of tests.
|
}); // End of tests.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ const api = supertest('http://'+settings.ip+":"+settings.port);
|
||||||
const apiKey = common.apiKey;
|
const apiKey = common.apiKey;
|
||||||
var apiVersion = '1.2.14';
|
var apiVersion = '1.2.14';
|
||||||
|
|
||||||
|
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) {
|
||||||
api.get('/api/')
|
api.get('/api/')
|
||||||
|
@ -41,6 +42,7 @@ describe('getStats', function(){
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var endPoint = function(point, version){
|
var endPoint = function(point, version){
|
||||||
version = version || apiVersion;
|
version = version || apiVersion;
|
||||||
|
|
|
@ -43,6 +43,7 @@ var ulSpaceHtml = '<!doctype html><html><body><ul class="bullet"> <li>one</li></
|
||||||
*/
|
*/
|
||||||
var expectedSpaceHtml = '<!doctype html><html><body><ul class="bullet"><li>one</ul></body></html>';
|
var expectedSpaceHtml = '<!doctype html><html><body><ul class="bullet"><li>one</ul></body></html>';
|
||||||
|
|
||||||
|
describe(__filename, function() {
|
||||||
describe('Connectivity', function() {
|
describe('Connectivity', function() {
|
||||||
it('can connect', function(done) {
|
it('can connect', function(done) {
|
||||||
api.get('/api/')
|
api.get('/api/')
|
||||||
|
@ -779,6 +780,7 @@ describe('copyPadWithoutHistory', function(){
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
-> movePadForce Test
|
-> movePadForce Test
|
||||||
|
|
|
@ -11,6 +11,7 @@ let authorID = '';
|
||||||
let sessionID = '';
|
let sessionID = '';
|
||||||
let padID = makeid();
|
let padID = makeid();
|
||||||
|
|
||||||
|
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() {
|
||||||
await api.get('/api/')
|
await api.get('/api/')
|
||||||
|
@ -280,6 +281,7 @@ describe('API: Misc', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ var assert = require('assert')
|
||||||
var npm = require("../../../../src/node_modules/npm/lib/npm.js");
|
var npm = require("../../../../src/node_modules/npm/lib/npm.js");
|
||||||
var nodeify = require('../../../../src/node_modules/nodeify');
|
var nodeify = require('../../../../src/node_modules/nodeify');
|
||||||
|
|
||||||
|
describe(__filename, function() {
|
||||||
describe('tidyHtml', function() {
|
describe('tidyHtml', function() {
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
npm.load({}, function(err) {
|
npm.load({}, function(err) {
|
||||||
|
@ -68,3 +69,4 @@ describe('tidyHtml', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -105,10 +105,9 @@ const tests = {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For each test..
|
describe(__filename, function() {
|
||||||
for (let test in tests) {
|
for (let test in tests) {
|
||||||
let testObj = tests[test];
|
let testObj = tests[test];
|
||||||
|
|
||||||
describe(test, function() {
|
describe(test, function() {
|
||||||
if (testObj.disabled) {
|
if (testObj.disabled) {
|
||||||
return xit("DISABLED:", test, function(done){
|
return xit("DISABLED:", test, function(done){
|
||||||
|
@ -150,10 +149,9 @@ for (let test in tests){
|
||||||
throw new Error();
|
throw new Error();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@ function m(mod) { return __dirname + '/../../../src/' + mod; }
|
||||||
const assert = require('assert').strict;
|
const assert = require('assert').strict;
|
||||||
const promises = require(m('node/utils/promises'));
|
const promises = require(m('node/utils/promises'));
|
||||||
|
|
||||||
describe('promises.timesLimit', async () => {
|
describe(__filename, function() {
|
||||||
|
describe('promises.timesLimit', function() {
|
||||||
let wantIndex = 0;
|
let wantIndex = 0;
|
||||||
const testPromises = [];
|
const testPromises = [];
|
||||||
const makePromise = (index) => {
|
const makePromise = (index) => {
|
||||||
|
@ -24,18 +25,18 @@ describe('promises.timesLimit', async () => {
|
||||||
const concurrency = 7;
|
const concurrency = 7;
|
||||||
const timesLimitPromise = promises.timesLimit(total, concurrency, makePromise);
|
const timesLimitPromise = promises.timesLimit(total, concurrency, makePromise);
|
||||||
|
|
||||||
it('honors concurrency', async () => {
|
it('honors concurrency', async function() {
|
||||||
assert.equal(wantIndex, concurrency);
|
assert.equal(wantIndex, concurrency);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('creates another when one completes', async () => {
|
it('creates another when one completes', async function() {
|
||||||
const {promise, resolve} = testPromises.shift();
|
const {promise, resolve} = testPromises.shift();
|
||||||
resolve();
|
resolve();
|
||||||
await promise;
|
await promise;
|
||||||
assert.equal(wantIndex, concurrency + 1);
|
assert.equal(wantIndex, concurrency + 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('creates the expected total number of promises', async () => {
|
it('creates the expected total number of promises', async function() {
|
||||||
while (testPromises.length > 0) {
|
while (testPromises.length > 0) {
|
||||||
// Resolve them in random order to ensure that the resolution order doesn't matter.
|
// Resolve them in random order to ensure that the resolution order doesn't matter.
|
||||||
const i = Math.floor(Math.random() * Math.floor(testPromises.length));
|
const i = Math.floor(Math.random() * Math.floor(testPromises.length));
|
||||||
|
@ -46,11 +47,11 @@ describe('promises.timesLimit', async () => {
|
||||||
assert.equal(wantIndex, total);
|
assert.equal(wantIndex, total);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('resolves', async () => {
|
it('resolves', async function() {
|
||||||
await timesLimitPromise;
|
await timesLimitPromise;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not create too many promises if total < concurrency', async () => {
|
it('does not create too many promises if total < concurrency', async function() {
|
||||||
wantIndex = 0;
|
wantIndex = 0;
|
||||||
assert.equal(testPromises.length, 0);
|
assert.equal(testPromises.length, 0);
|
||||||
const total = 7;
|
const total = 7;
|
||||||
|
@ -65,21 +66,22 @@ describe('promises.timesLimit', async () => {
|
||||||
assert.equal(wantIndex, total);
|
assert.equal(wantIndex, total);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts total === 0, concurrency > 0', async () => {
|
it('accepts total === 0, concurrency > 0', async function() {
|
||||||
wantIndex = 0;
|
wantIndex = 0;
|
||||||
assert.equal(testPromises.length, 0);
|
assert.equal(testPromises.length, 0);
|
||||||
await promises.timesLimit(0, concurrency, makePromise);
|
await promises.timesLimit(0, concurrency, makePromise);
|
||||||
assert.equal(wantIndex, 0);
|
assert.equal(wantIndex, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts total === 0, concurrency === 0', async () => {
|
it('accepts total === 0, concurrency === 0', async function() {
|
||||||
wantIndex = 0;
|
wantIndex = 0;
|
||||||
assert.equal(testPromises.length, 0);
|
assert.equal(testPromises.length, 0);
|
||||||
await promises.timesLimit(0, 0, makePromise);
|
await promises.timesLimit(0, 0, makePromise);
|
||||||
assert.equal(wantIndex, 0);
|
assert.equal(wantIndex, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects total > 0, concurrency === 0', async () => {
|
it('rejects total > 0, concurrency === 0', async function() {
|
||||||
await assert.rejects(promises.timesLimit(total, 0, makePromise), RangeError);
|
await assert.rejects(promises.timesLimit(total, 0, makePromise), RangeError);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -9,9 +9,6 @@ const setCookieParser = require(m('node_modules/set-cookie-parser'));
|
||||||
const settings = require(m('node/utils/Settings'));
|
const settings = require(m('node/utils/Settings'));
|
||||||
|
|
||||||
const logger = common.logger;
|
const logger = common.logger;
|
||||||
let agent;
|
|
||||||
|
|
||||||
before(async function() { agent = await common.init(); });
|
|
||||||
|
|
||||||
// Waits for and returns the next named socket.io event. Rejects if there is any error while waiting
|
// Waits for and returns the next named socket.io event. Rejects if there is any error while waiting
|
||||||
// (unless waiting for that error event).
|
// (unless waiting for that error event).
|
||||||
|
@ -92,6 +89,10 @@ const handshake = async (socket, padID) => {
|
||||||
return msg;
|
return msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
describe(__filename, function() {
|
||||||
|
let agent;
|
||||||
|
before(async function() { agent = await common.init(); });
|
||||||
|
|
||||||
describe('socket.io access checks', function() {
|
describe('socket.io access checks', function() {
|
||||||
let authorize;
|
let authorize;
|
||||||
let authorizeHooksBackup;
|
let authorizeHooksBackup;
|
||||||
|
@ -353,3 +354,4 @@ describe('socket.io access checks', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -5,8 +5,8 @@ const common = require('../common');
|
||||||
const plugins = require(m('static/js/pluginfw/plugin_defs'));
|
const plugins = require(m('static/js/pluginfw/plugin_defs'));
|
||||||
const settings = require(m('node/utils/Settings'));
|
const settings = require(m('node/utils/Settings'));
|
||||||
|
|
||||||
|
describe(__filename, function() {
|
||||||
let agent;
|
let agent;
|
||||||
|
|
||||||
before(async function() { agent = await common.init(); });
|
before(async function() { agent = await common.init(); });
|
||||||
|
|
||||||
describe('webaccess: without plugins', function() {
|
describe('webaccess: without plugins', function() {
|
||||||
|
@ -442,3 +442,4 @@ describe('webaccess: authnFailure, authzFailure, authFailure hooks', function()
|
||||||
assert(!handlers['authFailure'].called);
|
assert(!handlers['authFailure'].called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue