mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-06-15 10:44:41 -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,7 +18,8 @@ var apiVersion = 1;
|
||||||
|
|
||||||
var testPadId = makeid();
|
var testPadId = makeid();
|
||||||
|
|
||||||
describe('API Versioning', function() {
|
describe(__filename, function() {
|
||||||
|
describe('API Versioning', function() {
|
||||||
it('errors if can not connect', function(done) {
|
it('errors if can not connect', function(done) {
|
||||||
api
|
api
|
||||||
.get('/api/')
|
.get('/api/')
|
||||||
|
@ -29,9 +30,9 @@ describe('API Versioning', function() {
|
||||||
})
|
})
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('OpenAPI definition', function() {
|
describe('OpenAPI definition', function() {
|
||||||
it('generates valid openapi definition document', function(done) {
|
it('generates valid openapi definition document', function(done) {
|
||||||
api
|
api
|
||||||
.get('/api/openapi.json')
|
.get('/api/openapi.json')
|
||||||
|
@ -45,9 +46,9 @@ describe('OpenAPI definition', function() {
|
||||||
})
|
})
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('jsonp support', function() {
|
describe('jsonp support', function() {
|
||||||
it('supports jsonp calls', function(done) {
|
it('supports jsonp calls', function(done) {
|
||||||
api
|
api
|
||||||
.get(endPoint('createPad') + '&jsonp=jsonp_1&padID=' + testPadId)
|
.get(endPoint('createPad') + '&jsonp=jsonp_1&padID=' + testPadId)
|
||||||
|
@ -57,6 +58,7 @@ describe('jsonp support', function() {
|
||||||
.expect('Content-Type', /javascript/)
|
.expect('Content-Type', /javascript/)
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var endPoint = function(point) {
|
var endPoint = function(point) {
|
||||||
|
|
|
@ -14,15 +14,16 @@ const apiKey = common.apiKey;
|
||||||
var apiVersion = 1;
|
var apiVersion = 1;
|
||||||
var testPadId = makeid();
|
var testPadId = makeid();
|
||||||
|
|
||||||
describe('Connectivity For Character Encoding', function(){
|
describe(__filename, function() {
|
||||||
|
describe('Connectivity For Character Encoding', function() {
|
||||||
it('can connect', function(done) {
|
it('can connect', function(done) {
|
||||||
api.get('/api/')
|
api.get('/api/')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('API Versioning', function(){
|
describe('API Versioning', function() {
|
||||||
it('finds the version tag', function(done) {
|
it('finds the version tag', function(done) {
|
||||||
api.get('/api/')
|
api.get('/api/')
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -32,9 +33,9 @@ describe('API Versioning', function(){
|
||||||
})
|
})
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Permission', function(){
|
describe('Permission', function() {
|
||||||
it('errors with invalid APIKey', function(done) {
|
it('errors with invalid APIKey', function(done) {
|
||||||
// This is broken because Etherpad doesn't handle HTTP codes properly see #2343
|
// 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
|
// If your APIKey is password you deserve to fail all tests anyway
|
||||||
|
@ -42,9 +43,9 @@ describe('Permission', function(){
|
||||||
api.get(permErrorURL)
|
api.get(permErrorURL)
|
||||||
.expect(401, done)
|
.expect(401, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('createPad', function(){
|
describe('createPad', function() {
|
||||||
it('creates a new Pad', function(done) {
|
it('creates a new Pad', function(done) {
|
||||||
api.get(endPoint('createPad')+"&padID="+testPadId)
|
api.get(endPoint('createPad')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -53,9 +54,9 @@ describe('createPad', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('setHTML', function(){
|
describe('setHTML', function() {
|
||||||
it('Sets the HTML of a Pad attempting to weird utf8 encoded content', function(done) {
|
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) {
|
fs.readFile('../tests/backend/specs/api/emojis.html', 'utf8', function(err, html) {
|
||||||
api.post(endPoint('setHTML'))
|
api.post(endPoint('setHTML'))
|
||||||
|
@ -70,9 +71,9 @@ describe('setHTML', function(){
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getHTML', function(){
|
describe('getHTML', function() {
|
||||||
it('get the HTML of Pad with emojis', function(done) {
|
it('get the HTML of Pad with emojis', function(done) {
|
||||||
api.get(endPoint('getHTML')+"&padID="+testPadId)
|
api.get(endPoint('getHTML')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -83,7 +84,8 @@ describe('getHTML', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,8 @@ var authorID = "";
|
||||||
var padID = makeid();
|
var padID = makeid();
|
||||||
var timestamp = Date.now();
|
var timestamp = Date.now();
|
||||||
|
|
||||||
describe('API Versioning', function(){
|
describe(__filename, 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/')
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -21,21 +22,21 @@ describe('API Versioning', function(){
|
||||||
})
|
})
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
// BEGIN GROUP AND AUTHOR TESTS
|
// BEGIN GROUP AND AUTHOR TESTS
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
/* Tests performed
|
/* Tests performed
|
||||||
-> createPad(padID)
|
-> createPad(padID)
|
||||||
-> createAuthor([name]) -- should return an authorID
|
-> createAuthor([name]) -- should return an authorID
|
||||||
-> appendChatMessage(padID, text, authorID, time)
|
-> appendChatMessage(padID, text, authorID, time)
|
||||||
-> getChatHead(padID)
|
-> getChatHead(padID)
|
||||||
-> getChatHistory(padID)
|
-> getChatHistory(padID)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
describe('createPad', function(){
|
describe('createPad', function(){
|
||||||
it('creates a new Pad', function(done) {
|
it('creates a new Pad', function(done) {
|
||||||
api.get(endPoint('createPad')+"&padID="+padID)
|
api.get(endPoint('createPad')+"&padID="+padID)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -44,9 +45,9 @@ describe('createPad', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('createAuthor', function(){
|
describe('createAuthor', 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(function(res){
|
.expect(function(res){
|
||||||
|
@ -56,9 +57,9 @@ describe('createAuthor', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('appendChatMessage', function(){
|
describe('appendChatMessage', function(){
|
||||||
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(function(res){
|
.expect(function(res){
|
||||||
|
@ -67,10 +68,10 @@ describe('appendChatMessage', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
describe('getChatHead', function(){
|
describe('getChatHead', function(){
|
||||||
it('Gets the head of chat', function(done) {
|
it('Gets the head of chat', function(done) {
|
||||||
api.get(endPoint('getChatHead')+"&padID="+padID)
|
api.get(endPoint('getChatHead')+"&padID="+padID)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -81,9 +82,9 @@ describe('getChatHead', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getChatHistory', function(){
|
describe('getChatHistory', 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(function(res){
|
.expect(function(res){
|
||||||
|
@ -93,7 +94,8 @@ describe('getChatHistory', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.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,13 +56,14 @@ var testImports = {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(testImports).forEach(function (testName) {
|
describe(__filename, function() {
|
||||||
|
Object.keys(testImports).forEach(function(testName) {
|
||||||
var testPadId = makeid();
|
var testPadId = makeid();
|
||||||
test = testImports[testName];
|
test = testImports[testName];
|
||||||
describe('createPad', function(){
|
describe('createPad', function() {
|
||||||
it('creates a new Pad', function(done) {
|
it('creates a new Pad', function(done) {
|
||||||
api.get(endPoint('createPad')+"&padID="+testPadId)
|
api.get(endPoint('createPad') + "&padID=" + testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res) {
|
||||||
if(res.body.code !== 0) throw new Error("Unable to create new Pad");
|
if(res.body.code !== 0) throw new Error("Unable to create new Pad");
|
||||||
})
|
})
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
|
@ -70,21 +71,21 @@ Object.keys(testImports).forEach(function (testName) {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('setHTML', function(){
|
describe('setHTML', function() {
|
||||||
it('Sets the HTML', function(done) {
|
it('Sets the HTML', function(done) {
|
||||||
api.get(endPoint('setHTML')+"&padID="+testPadId+"&html="+test.input)
|
api.get(endPoint('setHTML') + "&padID=" + testPadId + "&html=" + test.input)
|
||||||
.expect(function(res){
|
.expect(function(res) {
|
||||||
if(res.body.code !== 0) throw new Error("Error:"+testName)
|
if(res.body.code !== 0) throw new Error("Error:" + testName)
|
||||||
})
|
})
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getHTML', function(){
|
describe('getHTML', function() {
|
||||||
it('Gets back the HTML of a Pad', function(done) {
|
it('Gets back the HTML of a Pad', function(done) {
|
||||||
api.get(endPoint('getHTML')+"&padID="+testPadId)
|
api.get(endPoint('getHTML') + "&padID=" + testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res) {
|
||||||
var receivedHtml = res.body.data.html;
|
var receivedHtml = res.body.data.html;
|
||||||
if (receivedHtml !== test.expectedHTML) {
|
if (receivedHtml !== test.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.
|
||||||
|
@ -106,10 +107,10 @@ Object.keys(testImports).forEach(function (testName) {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getText', function(){
|
describe('getText', function() {
|
||||||
it('Gets back the Text of a Pad', function(done) {
|
it('Gets back the Text of a Pad', function(done) {
|
||||||
api.get(endPoint('getText')+"&padID="+testPadId)
|
api.get(endPoint('getText') + "&padID=" + testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res) {
|
||||||
var receivedText = res.body.data.text;
|
var receivedText = res.body.data.text;
|
||||||
if (receivedText !== test.expectedText) {
|
if (receivedText !== test.expectedText) {
|
||||||
throw new Error(`Text received from export is not the one we were expecting.
|
throw new Error(`Text received from export is not the one we were expecting.
|
||||||
|
@ -130,6 +131,7 @@ Object.keys(testImports).forEach(function (testName) {
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,51 +23,52 @@ var apiVersion = 1;
|
||||||
const testPadId = makeid();
|
const testPadId = makeid();
|
||||||
const testPadIdEnc = encodeURIComponent(testPadId);
|
const testPadIdEnc = encodeURIComponent(testPadId);
|
||||||
|
|
||||||
before(async function() { agent = await common.init(); });
|
describe(__filename, function() {
|
||||||
|
before(async function() { agent = await common.init(); });
|
||||||
|
|
||||||
describe('Connectivity', function(){
|
describe('Connectivity', function(){
|
||||||
it('can connect', async function() {
|
it('can connect', async function() {
|
||||||
await agent.get('/api/')
|
await agent.get('/api/')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.expect('Content-Type', /json/);
|
.expect('Content-Type', /json/);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('API Versioning', function(){
|
describe('API Versioning', function(){
|
||||||
it('finds the version tag', async function() {
|
it('finds the version tag', async function() {
|
||||||
await agent.get('/api/')
|
await agent.get('/api/')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.expect((res) => assert(res.body.currentVersion));
|
.expect((res) => assert(res.body.currentVersion));
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Tests
|
Tests
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Test.
|
Test.
|
||||||
/ Create a pad
|
/ Create a pad
|
||||||
/ Set pad contents
|
/ Set pad contents
|
||||||
/ Try export pad in various formats
|
/ Try export pad in various formats
|
||||||
/ Get pad contents and ensure it matches imported contents
|
/ Get pad contents and ensure it matches imported contents
|
||||||
|
|
||||||
Test.
|
Test.
|
||||||
/ Try to export a pad that doesn't exist // Expect failure
|
/ Try to export a pad that doesn't exist // Expect failure
|
||||||
|
|
||||||
Test.
|
Test.
|
||||||
/ Try to import an unsupported file to a pad that exists
|
/ Try to import an unsupported file to a pad that exists
|
||||||
|
|
||||||
-- TODO: Test.
|
-- TODO: Test.
|
||||||
Try to import to a file and abort it half way through
|
Try to import to a file and abort it half way through
|
||||||
|
|
||||||
Test.
|
Test.
|
||||||
Try to import to files of varying size.
|
Try to import to files of varying size.
|
||||||
|
|
||||||
Example Curl command for testing import URI:
|
Example Curl command for testing import URI:
|
||||||
curl -s -v --form file=@/home/jose/test.txt http://127.0.0.1:9001/p/foo/import
|
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 = {};
|
const backups = {};
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(async 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,18 +11,19 @@ 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('Connectivity for instance-level API tests', function() {
|
describe(__filename, 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/')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getStats', function(){
|
describe('getStats', function() {
|
||||||
it('Gets the stats of a running instance', function(done) {
|
it('Gets the stats of a running instance', function(done) {
|
||||||
api.get(endPoint('getStats'))
|
api.get(endPoint('getStats'))
|
||||||
.expect(function(res){
|
.expect(function(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'))) {
|
||||||
|
@ -40,6 +41,7 @@ describe('getStats', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var endPoint = function(point, version){
|
var endPoint = function(point, version){
|
||||||
|
|
|
@ -43,15 +43,16 @@ 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('Connectivity', function(){
|
describe(__filename, function() {
|
||||||
|
describe('Connectivity', function() {
|
||||||
it('can connect', function(done) {
|
it('can connect', function(done) {
|
||||||
api.get('/api/')
|
api.get('/api/')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('API Versioning', function(){
|
describe('API Versioning', function(){
|
||||||
it('finds the version tag', function(done) {
|
it('finds the version tag', function(done) {
|
||||||
api.get('/api/')
|
api.get('/api/')
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -61,9 +62,9 @@ describe('API Versioning', function(){
|
||||||
})
|
})
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Permission', function(){
|
describe('Permission', function(){
|
||||||
it('errors with invalid APIKey', function(done) {
|
it('errors with invalid APIKey', function(done) {
|
||||||
// This is broken because Etherpad doesn't handle HTTP codes properly see #2343
|
// 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
|
// If your APIKey is password you deserve to fail all tests anyway
|
||||||
|
@ -71,10 +72,10 @@ describe('Permission', function(){
|
||||||
api.get(permErrorURL)
|
api.get(permErrorURL)
|
||||||
.expect(401, done)
|
.expect(401, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
/* Pad Tests Order of execution
|
/* Pad Tests Order of execution
|
||||||
-> deletePad -- This gives us a guaranteed clear environment
|
-> deletePad -- This gives us a guaranteed clear environment
|
||||||
-> createPad
|
-> createPad
|
||||||
-> getRevisions -- Should be 0
|
-> getRevisions -- Should be 0
|
||||||
-> getSavedRevisionsCount(padID) -- Should be 0
|
-> getSavedRevisionsCount(padID) -- Should be 0
|
||||||
|
@ -113,17 +114,17 @@ describe('Permission', function(){
|
||||||
-> getHTML(padID) -- Should return HTML close to posted HTML
|
-> getHTML(padID) -- Should return HTML close to posted HTML
|
||||||
-> createPad -- Tries to create pads with bad url characters
|
-> createPad -- Tries to create pads with bad url characters
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
describe('deletePad', function(){
|
describe('deletePad', function(){
|
||||||
it('deletes a Pad', function(done) {
|
it('deletes a Pad', function(done) {
|
||||||
api.get(endPoint('deletePad')+"&padID="+testPadId)
|
api.get(endPoint('deletePad')+"&padID="+testPadId)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done) // @TODO: we shouldn't expect 200 here since the pad may not exist
|
.expect(200, done) // @TODO: we shouldn't expect 200 here since the pad may not exist
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('createPad', function(){
|
describe('createPad', function(){
|
||||||
it('creates a new Pad', function(done) {
|
it('creates a new Pad', function(done) {
|
||||||
api.get(endPoint('createPad')+"&padID="+testPadId)
|
api.get(endPoint('createPad')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -132,9 +133,9 @@ describe('createPad', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getRevisionsCount', function(){
|
describe('getRevisionsCount', function(){
|
||||||
it('gets revision count of Pad', function(done) {
|
it('gets revision count of Pad', function(done) {
|
||||||
api.get(endPoint('getRevisionsCount')+"&padID="+testPadId)
|
api.get(endPoint('getRevisionsCount')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -144,9 +145,9 @@ describe('getRevisionsCount', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getSavedRevisionsCount', function(){
|
describe('getSavedRevisionsCount', function(){
|
||||||
it('gets saved revisions count of Pad', function(done) {
|
it('gets saved revisions count of Pad', function(done) {
|
||||||
api.get(endPoint('getSavedRevisionsCount')+"&padID="+testPadId)
|
api.get(endPoint('getSavedRevisionsCount')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -156,9 +157,9 @@ describe('getSavedRevisionsCount', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('listSavedRevisions', function(){
|
describe('listSavedRevisions', function(){
|
||||||
it('gets saved revision list of Pad', function(done) {
|
it('gets saved revision list of Pad', function(done) {
|
||||||
api.get(endPoint('listSavedRevisions')+"&padID="+testPadId)
|
api.get(endPoint('listSavedRevisions')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -168,9 +169,9 @@ describe('listSavedRevisions', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getHTML', function(){
|
describe('getHTML', function(){
|
||||||
it('get the HTML of Pad', function(done) {
|
it('get the HTML of Pad', function(done) {
|
||||||
api.get(endPoint('getHTML')+"&padID="+testPadId)
|
api.get(endPoint('getHTML')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -179,9 +180,9 @@ describe('getHTML', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('listAllPads', function () {
|
describe('listAllPads', function () {
|
||||||
it('list all pads', function (done) {
|
it('list all pads', function (done) {
|
||||||
api.get(endPoint('listAllPads'))
|
api.get(endPoint('listAllPads'))
|
||||||
.expect(function (res) {
|
.expect(function (res) {
|
||||||
|
@ -192,9 +193,9 @@ describe('listAllPads', function () {
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('deletePad', function(){
|
describe('deletePad', function(){
|
||||||
it('deletes a Pad', function(done) {
|
it('deletes a Pad', function(done) {
|
||||||
api.get(endPoint('deletePad')+"&padID="+testPadId)
|
api.get(endPoint('deletePad')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -203,9 +204,9 @@ describe('deletePad', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('listAllPads', function () {
|
describe('listAllPads', function () {
|
||||||
it('list all pads', function (done) {
|
it('list all pads', function (done) {
|
||||||
api.get(endPoint('listAllPads'))
|
api.get(endPoint('listAllPads'))
|
||||||
.expect(function (res) {
|
.expect(function (res) {
|
||||||
|
@ -216,9 +217,9 @@ describe('listAllPads', function () {
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getHTML', function(){
|
describe('getHTML', function(){
|
||||||
it('get the HTML of a Pad -- Should return a failure', function(done) {
|
it('get the HTML of a Pad -- Should return a failure', function(done) {
|
||||||
api.get(endPoint('getHTML')+"&padID="+testPadId)
|
api.get(endPoint('getHTML')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -227,9 +228,9 @@ describe('getHTML', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('createPad', function(){
|
describe('createPad', function(){
|
||||||
it('creates a new Pad with text', function(done) {
|
it('creates a new Pad with text', function(done) {
|
||||||
api.get(endPoint('createPad')+"&padID="+testPadId+"&text=testText")
|
api.get(endPoint('createPad')+"&padID="+testPadId+"&text=testText")
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -238,9 +239,9 @@ describe('createPad', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getText', function(){
|
describe('getText', function(){
|
||||||
it('gets the Pad text and expect it to be testText with \n which is a line break', function(done) {
|
it('gets the Pad text and expect it to be testText with \n which is a line break', function(done) {
|
||||||
api.get(endPoint('getText')+"&padID="+testPadId)
|
api.get(endPoint('getText')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -249,9 +250,9 @@ describe('getText', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('setText', function(){
|
describe('setText', function(){
|
||||||
it('creates a new Pad with text', function(done) {
|
it('creates a new Pad with text', function(done) {
|
||||||
api.post(endPoint('setText'))
|
api.post(endPoint('setText'))
|
||||||
.send({
|
.send({
|
||||||
|
@ -264,9 +265,9 @@ describe('setText', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getText', function(){
|
describe('getText', function(){
|
||||||
it('gets the Pad text', function(done) {
|
it('gets the Pad text', function(done) {
|
||||||
api.get(endPoint('getText')+"&padID="+testPadId)
|
api.get(endPoint('getText')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -275,9 +276,9 @@ describe('getText', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getRevisionsCount', function(){
|
describe('getRevisionsCount', function(){
|
||||||
it('gets Revision Count of a Pad', function(done) {
|
it('gets Revision Count of a Pad', function(done) {
|
||||||
api.get(endPoint('getRevisionsCount')+"&padID="+testPadId)
|
api.get(endPoint('getRevisionsCount')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -286,9 +287,9 @@ describe('getRevisionsCount', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('saveRevision', function(){
|
describe('saveRevision', function(){
|
||||||
it('saves Revision', function(done) {
|
it('saves Revision', function(done) {
|
||||||
api.get(endPoint('saveRevision')+"&padID="+testPadId)
|
api.get(endPoint('saveRevision')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -297,9 +298,9 @@ describe('saveRevision', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getSavedRevisionsCount', function(){
|
describe('getSavedRevisionsCount', function(){
|
||||||
it('gets saved revisions count of Pad', function(done) {
|
it('gets saved revisions count of Pad', function(done) {
|
||||||
api.get(endPoint('getSavedRevisionsCount')+"&padID="+testPadId)
|
api.get(endPoint('getSavedRevisionsCount')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -309,9 +310,9 @@ describe('getSavedRevisionsCount', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('listSavedRevisions', function(){
|
describe('listSavedRevisions', function(){
|
||||||
it('gets saved revision list of Pad', function(done) {
|
it('gets saved revision list of Pad', function(done) {
|
||||||
api.get(endPoint('listSavedRevisions')+"&padID="+testPadId)
|
api.get(endPoint('listSavedRevisions')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -321,8 +322,8 @@ describe('listSavedRevisions', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
describe('padUsersCount', function(){
|
describe('padUsersCount', function(){
|
||||||
it('gets User Count of a Pad', function(done) {
|
it('gets User Count of a Pad', function(done) {
|
||||||
api.get(endPoint('padUsersCount')+"&padID="+testPadId)
|
api.get(endPoint('padUsersCount')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -331,9 +332,9 @@ describe('padUsersCount', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getReadOnlyID', function(){
|
describe('getReadOnlyID', function(){
|
||||||
it('Gets the Read Only ID of a Pad', function(done) {
|
it('Gets the Read Only ID of a Pad', function(done) {
|
||||||
api.get(endPoint('getReadOnlyID')+"&padID="+testPadId)
|
api.get(endPoint('getReadOnlyID')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -342,9 +343,9 @@ describe('getReadOnlyID', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('listAuthorsOfPad', function(){
|
describe('listAuthorsOfPad', function(){
|
||||||
it('Get Authors of the Pad', function(done) {
|
it('Get Authors of the Pad', function(done) {
|
||||||
api.get(endPoint('listAuthorsOfPad')+"&padID="+testPadId)
|
api.get(endPoint('listAuthorsOfPad')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -353,9 +354,9 @@ describe('listAuthorsOfPad', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getLastEdited', function(){
|
describe('getLastEdited', function(){
|
||||||
it('Get When Pad was left Edited', function(done) {
|
it('Get When Pad was left Edited', function(done) {
|
||||||
api.get(endPoint('getLastEdited')+"&padID="+testPadId)
|
api.get(endPoint('getLastEdited')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -368,9 +369,9 @@ describe('getLastEdited', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('setText', function(){
|
describe('setText', function(){
|
||||||
it('creates a new Pad with text', function(done) {
|
it('creates a new Pad with text', function(done) {
|
||||||
api.post(endPoint('setText'))
|
api.post(endPoint('setText'))
|
||||||
.send({
|
.send({
|
||||||
|
@ -383,9 +384,9 @@ describe('setText', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getLastEdited', function(){
|
describe('getLastEdited', function(){
|
||||||
it('Get When Pad was left Edited', function(done) {
|
it('Get When Pad was left Edited', function(done) {
|
||||||
api.get(endPoint('getLastEdited')+"&padID="+testPadId)
|
api.get(endPoint('getLastEdited')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -396,9 +397,9 @@ describe('getLastEdited', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('padUsers', function(){
|
describe('padUsers', function(){
|
||||||
it('gets User Count of a Pad', function(done) {
|
it('gets User Count of a Pad', function(done) {
|
||||||
api.get(endPoint('padUsers')+"&padID="+testPadId)
|
api.get(endPoint('padUsers')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -407,9 +408,9 @@ describe('padUsers', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('deletePad', function(){
|
describe('deletePad', function(){
|
||||||
it('deletes a Pad', function(done) {
|
it('deletes a Pad', function(done) {
|
||||||
api.get(endPoint('deletePad')+"&padID="+testPadId)
|
api.get(endPoint('deletePad')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -418,13 +419,13 @@ describe('deletePad', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
var originalPadId = testPadId;
|
var originalPadId = testPadId;
|
||||||
var newPadId = makeid();
|
var newPadId = makeid();
|
||||||
var copiedPadId = makeid();
|
var copiedPadId = makeid();
|
||||||
|
|
||||||
describe('createPad', function(){
|
describe('createPad', function(){
|
||||||
it('creates a new Pad with text', function(done) {
|
it('creates a new Pad with text', function(done) {
|
||||||
api.get(endPoint('createPad')+"&padID="+testPadId)
|
api.get(endPoint('createPad')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -433,9 +434,9 @@ describe('createPad', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('setText', function(){
|
describe('setText', function(){
|
||||||
it('Sets text on a pad Id', function(done) {
|
it('Sets text on a pad Id', function(done) {
|
||||||
api.post(endPoint('setText')+"&padID="+testPadId)
|
api.post(endPoint('setText')+"&padID="+testPadId)
|
||||||
.field({text: text})
|
.field({text: text})
|
||||||
|
@ -445,9 +446,9 @@ describe('setText', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getText', function(){
|
describe('getText', function(){
|
||||||
it('Gets text on a pad Id', function(done) {
|
it('Gets text on a pad Id', function(done) {
|
||||||
api.get(endPoint('getText')+"&padID="+testPadId)
|
api.get(endPoint('getText')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -457,9 +458,9 @@ describe('getText', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('setText', function(){
|
describe('setText', function(){
|
||||||
it('Sets text on a pad Id including an explicit newline', function(done) {
|
it('Sets text on a pad Id including an explicit newline', function(done) {
|
||||||
api.post(endPoint('setText')+"&padID="+testPadId)
|
api.post(endPoint('setText')+"&padID="+testPadId)
|
||||||
.field({text: text+'\n'})
|
.field({text: text+'\n'})
|
||||||
|
@ -469,9 +470,9 @@ describe('setText', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getText', function(){
|
describe('getText', function(){
|
||||||
it("Gets text on a pad Id and doesn't have an excess newline", function(done) {
|
it("Gets text on a pad Id and doesn't have an excess newline", function(done) {
|
||||||
api.get(endPoint('getText')+"&padID="+testPadId)
|
api.get(endPoint('getText')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -481,9 +482,9 @@ describe('getText', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getLastEdited', function(){
|
describe('getLastEdited', function(){
|
||||||
it('Gets when pad was last edited', function(done) {
|
it('Gets when pad was last edited', function(done) {
|
||||||
api.get(endPoint('getLastEdited')+"&padID="+testPadId)
|
api.get(endPoint('getLastEdited')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -492,9 +493,9 @@ describe('getLastEdited', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('movePad', function(){
|
describe('movePad', function(){
|
||||||
it('Move a Pad to a different Pad ID', function(done) {
|
it('Move a Pad to a different Pad ID', function(done) {
|
||||||
api.get(endPoint('movePad')+"&sourceID="+testPadId+"&destinationID="+newPadId+"&force=true")
|
api.get(endPoint('movePad')+"&sourceID="+testPadId+"&destinationID="+newPadId+"&force=true")
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -503,9 +504,9 @@ describe('movePad', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getText', function(){
|
describe('getText', function(){
|
||||||
it('Gets text on a pad Id', function(done) {
|
it('Gets text on a pad Id', function(done) {
|
||||||
api.get(endPoint('getText')+"&padID="+newPadId)
|
api.get(endPoint('getText')+"&padID="+newPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -514,9 +515,9 @@ describe('getText', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('movePad', function(){
|
describe('movePad', function(){
|
||||||
it('Move a Pad to a different Pad ID', function(done) {
|
it('Move a Pad to a different Pad ID', function(done) {
|
||||||
api.get(endPoint('movePad')+"&sourceID="+newPadId+"&destinationID="+testPadId+"&force=false")
|
api.get(endPoint('movePad')+"&sourceID="+newPadId+"&destinationID="+testPadId+"&force=false")
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -525,9 +526,9 @@ describe('movePad', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getText', function(){
|
describe('getText', function(){
|
||||||
it('Gets text on a pad Id', function(done) {
|
it('Gets text on a pad Id', function(done) {
|
||||||
api.get(endPoint('getText')+"&padID="+testPadId)
|
api.get(endPoint('getText')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -536,9 +537,9 @@ describe('getText', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getLastEdited', function(){
|
describe('getLastEdited', function(){
|
||||||
it('Gets when pad was last edited', function(done) {
|
it('Gets when pad was last edited', function(done) {
|
||||||
api.get(endPoint('getLastEdited')+"&padID="+testPadId)
|
api.get(endPoint('getLastEdited')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -547,9 +548,9 @@ describe('getLastEdited', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('appendText', function(){
|
describe('appendText', function(){
|
||||||
it('Append text to a pad Id', function(done) {
|
it('Append text to a pad Id', function(done) {
|
||||||
api.get(endPoint('appendText', '1.2.13')+"&padID="+testPadId+"&text=hello")
|
api.get(endPoint('appendText', '1.2.13')+"&padID="+testPadId+"&text=hello")
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -558,9 +559,9 @@ describe('appendText', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getText', function(){
|
describe('getText', function(){
|
||||||
it('Gets text on a pad Id', function(done) {
|
it('Gets text on a pad Id', function(done) {
|
||||||
api.get(endPoint('getText')+"&padID="+testPadId)
|
api.get(endPoint('getText')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -570,10 +571,10 @@ describe('getText', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('setHTML', function(){
|
describe('setHTML', function(){
|
||||||
it('Sets the HTML of a Pad attempting to pass ugly HTML', function(done) {
|
it('Sets the HTML of a Pad attempting to pass ugly HTML', function(done) {
|
||||||
var html = "<div><b>Hello HTML</title></head></div>";
|
var html = "<div><b>Hello HTML</title></head></div>";
|
||||||
api.post(endPoint('setHTML'))
|
api.post(endPoint('setHTML'))
|
||||||
|
@ -587,9 +588,9 @@ describe('setHTML', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('setHTML', function(){
|
describe('setHTML', function(){
|
||||||
it('Sets the HTML of a Pad with complex nested lists of different types', function(done) {
|
it('Sets the HTML of a Pad with complex nested lists of different types', function(done) {
|
||||||
api.post(endPoint('setHTML'))
|
api.post(endPoint('setHTML'))
|
||||||
.send({
|
.send({
|
||||||
|
@ -602,9 +603,9 @@ describe('setHTML', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getHTML', function(){
|
describe('getHTML', function(){
|
||||||
it('Gets back the HTML of a Pad with complex nested lists of different types', function(done) {
|
it('Gets back the HTML of a Pad with complex nested lists of different types', function(done) {
|
||||||
api.get(endPoint('getHTML')+"&padID="+testPadId)
|
api.get(endPoint('getHTML')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -625,9 +626,9 @@ describe('getHTML', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('setHTML', function(){
|
describe('setHTML', function(){
|
||||||
it('Sets the HTML of a Pad with white space between list items', function(done) {
|
it('Sets the HTML of a Pad with white space between list items', function(done) {
|
||||||
api.get(endPoint('setHTML')+"&padID="+testPadId+"&html="+ulSpaceHtml)
|
api.get(endPoint('setHTML')+"&padID="+testPadId+"&html="+ulSpaceHtml)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -636,9 +637,9 @@ describe('setHTML', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getHTML', function(){
|
describe('getHTML', function(){
|
||||||
it('Gets back the HTML of a Pad with complex nested lists of different types', function(done) {
|
it('Gets back the HTML of a Pad with complex nested lists of different types', function(done) {
|
||||||
api.get(endPoint('getHTML')+"&padID="+testPadId)
|
api.get(endPoint('getHTML')+"&padID="+testPadId)
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -658,9 +659,9 @@ describe('getHTML', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('createPad', function(){
|
describe('createPad', function(){
|
||||||
it('errors if pad can be created', function(done) {
|
it('errors if pad can be created', function(done) {
|
||||||
var badUrlChars = ["/", "%23", "%3F", "%26"];
|
var badUrlChars = ["/", "%23", "%3F", "%26"];
|
||||||
async.map(
|
async.map(
|
||||||
|
@ -675,9 +676,9 @@ describe('createPad', function(){
|
||||||
},
|
},
|
||||||
done);
|
done);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
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) {
|
||||||
api.get(endPoint('copyPad')+"&sourceID="+testPadId+"&destinationID="+copiedPadId+"&force=true")
|
api.get(endPoint('copyPad')+"&sourceID="+testPadId+"&destinationID="+copiedPadId+"&force=true")
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
|
@ -686,9 +687,9 @@ describe('copyPad', function(){
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('copyPadWithoutHistory', function(){
|
describe('copyPadWithoutHistory', function(){
|
||||||
var sourcePadId = makeid();
|
var sourcePadId = makeid();
|
||||||
var newPad;
|
var newPad;
|
||||||
|
|
||||||
|
@ -778,7 +779,8 @@ describe('copyPadWithoutHistory', function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
-> movePadForce Test
|
-> movePadForce Test
|
||||||
|
|
|
@ -11,7 +11,8 @@ let authorID = '';
|
||||||
let sessionID = '';
|
let sessionID = '';
|
||||||
let padID = makeid();
|
let padID = makeid();
|
||||||
|
|
||||||
describe('API Versioning', function() {
|
describe(__filename, 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/')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
|
@ -20,14 +21,14 @@ describe('API Versioning', function() {
|
||||||
apiVersion = res.body.currentVersion;
|
apiVersion = res.body.currentVersion;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// BEGIN GROUP AND AUTHOR TESTS
|
// BEGIN GROUP AND AUTHOR TESTS
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
/* Tests performed
|
/* Tests performed
|
||||||
-> createGroup() -- should return a groupID
|
-> createGroup() -- should return a groupID
|
||||||
-> listSessionsOfGroup(groupID) -- should be 0
|
-> listSessionsOfGroup(groupID) -- should be 0
|
||||||
-> deleteGroup(groupID)
|
-> deleteGroup(groupID)
|
||||||
-> createGroupIfNotExistsFor(groupMapper) -- should return a groupID
|
-> createGroupIfNotExistsFor(groupMapper) -- should return a groupID
|
||||||
|
@ -36,23 +37,23 @@ describe('API Versioning', function() {
|
||||||
-> createAuthorIfNotExistsFor(authorMapper [, name]) -- should return an authorID
|
-> createAuthorIfNotExistsFor(authorMapper [, name]) -- should return an authorID
|
||||||
-> getAuthorName(authorID) -- should return a name IE "john"
|
-> getAuthorName(authorID) -- should return a name IE "john"
|
||||||
|
|
||||||
-> createSession(groupID, authorID, validUntil)
|
-> createSession(groupID, authorID, validUntil)
|
||||||
-> getSessionInfo(sessionID)
|
-> getSessionInfo(sessionID)
|
||||||
-> listSessionsOfGroup(groupID) -- should be 1
|
-> listSessionsOfGroup(groupID) -- should be 1
|
||||||
-> deleteSession(sessionID)
|
-> deleteSession(sessionID)
|
||||||
-> getSessionInfo(sessionID) -- should have author id etc in
|
-> getSessionInfo(sessionID) -- should have author id etc in
|
||||||
|
|
||||||
-> listPads(groupID) -- should be empty array
|
-> listPads(groupID) -- should be empty array
|
||||||
-> createGroupPad(groupID, padName [, text])
|
-> createGroupPad(groupID, padName [, text])
|
||||||
-> listPads(groupID) -- should be empty array
|
-> listPads(groupID) -- should be empty array
|
||||||
-> getPublicStatus(padId)
|
-> getPublicStatus(padId)
|
||||||
-> setPublicStatus(padId, status)
|
-> setPublicStatus(padId, status)
|
||||||
-> getPublicStatus(padId)
|
-> getPublicStatus(padId)
|
||||||
|
|
||||||
-> listPadsOfAuthor(authorID)
|
-> listPadsOfAuthor(authorID)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
describe('API: Group creation and deletion', function() {
|
describe('API: Group creation and deletion', function() {
|
||||||
it('createGroup', async function() {
|
it('createGroup', async function() {
|
||||||
await api.get(endPoint('createGroup'))
|
await api.get(endPoint('createGroup'))
|
||||||
.expect(200)
|
.expect(200)
|
||||||
|
@ -92,9 +93,9 @@ describe('API: Group creation and deletion', function() {
|
||||||
assert(res.body.data.groupID);
|
assert(res.body.data.groupID);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('API: Author creation', function() {
|
describe('API: Author creation', function() {
|
||||||
it('createGroup', async function() {
|
it('createGroup', async function() {
|
||||||
await api.get(endPoint('createGroup'))
|
await api.get(endPoint('createGroup'))
|
||||||
.expect(200)
|
.expect(200)
|
||||||
|
@ -146,9 +147,9 @@ describe('API: Author creation', function() {
|
||||||
assert.equal(res.body.data, 'john');
|
assert.equal(res.body.data, 'john');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('API: Sessions', function() {
|
describe('API: Sessions', function() {
|
||||||
it('createSession', async function() {
|
it('createSession', async function() {
|
||||||
await api.get(endPoint('createSession') +
|
await api.get(endPoint('createSession') +
|
||||||
`&authorID=${authorID}&groupID=${groupID}&validUntil=999999999999`)
|
`&authorID=${authorID}&groupID=${groupID}&validUntil=999999999999`)
|
||||||
|
@ -200,9 +201,9 @@ describe('API: Sessions', function() {
|
||||||
assert.equal(res.body.code, 1);
|
assert.equal(res.body.code, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('API: Group pad management', function() {
|
describe('API: Group pad management', function() {
|
||||||
it('listPads', async function() {
|
it('listPads', async function() {
|
||||||
await api.get(endPoint('listPads') + `&groupID=${groupID}`)
|
await api.get(endPoint('listPads') + `&groupID=${groupID}`)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
|
@ -232,9 +233,9 @@ describe('API: Group pad management', function() {
|
||||||
assert.equal(res.body.data.padIDs.length, 1);
|
assert.equal(res.body.data.padIDs.length, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('API: Pad security', function() {
|
describe('API: Pad security', function() {
|
||||||
it('getPublicStatus', async function() {
|
it('getPublicStatus', async function() {
|
||||||
await api.get(endPoint('getPublicStatus') + `&padID=${padID}`)
|
await api.get(endPoint('getPublicStatus') + `&padID=${padID}`)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
|
@ -263,13 +264,13 @@ describe('API: Pad security', function() {
|
||||||
assert.equal(res.body.data.publicStatus, true);
|
assert.equal(res.body.data.publicStatus, true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// NOT SURE HOW TO POPULAT THIS /-_-\
|
// NOT SURE HOW TO POPULAT THIS /-_-\
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
|
||||||
describe('API: Misc', function() {
|
describe('API: Misc', function() {
|
||||||
it('listPadsOfAuthor', async function() {
|
it('listPadsOfAuthor', async function() {
|
||||||
await api.get(endPoint('listPadsOfAuthor') + `&authorID=${authorID}`)
|
await api.get(endPoint('listPadsOfAuthor') + `&authorID=${authorID}`)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
|
@ -279,6 +280,7 @@ describe('API: Misc', function() {
|
||||||
assert.equal(res.body.data.padIDs.length, 0);
|
assert.equal(res.body.data.padIDs.length, 0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,8 @@ 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('tidyHtml', function() {
|
describe(__filename, function() {
|
||||||
|
describe('tidyHtml', function() {
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
npm.load({}, function(err) {
|
npm.load({}, function(err) {
|
||||||
assert.ok(!err);
|
assert.ok(!err);
|
||||||
|
@ -67,4 +68,5 @@ describe('tidyHtml', function() {
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -105,12 +105,11 @@ 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){
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
|
@ -132,28 +131,27 @@ for (let test in tests){
|
||||||
var expectedText = testObj.expectedText;
|
var expectedText = testObj.expectedText;
|
||||||
|
|
||||||
// Check recieved text matches the expected text
|
// Check recieved text matches the expected text
|
||||||
if(arraysEqual(recievedText[0], expectedText)){
|
if (arraysEqual(recievedText[0], expectedText)) {
|
||||||
// console.log("PASS: Recieved Text did match Expected Text\nRecieved:", recievedText[0], "\nExpected:", testObj.expectedText)
|
// console.log("PASS: Recieved Text did match Expected Text\nRecieved:", recievedText[0], "\nExpected:", testObj.expectedText)
|
||||||
}else{
|
} else {
|
||||||
console.error("FAIL: Recieved Text did not match Expected Text\nRecieved:", recievedText[0], "\nExpected:", testObj.expectedText)
|
console.error("FAIL: Recieved Text did not match Expected Text\nRecieved:", recievedText[0], "\nExpected:", testObj.expectedText)
|
||||||
throw new Error();
|
throw new Error();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check recieved attributes matches the expected attributes
|
// Check recieved attributes matches the expected attributes
|
||||||
if(arraysEqual(recievedAttributes, expectedAttributes)){
|
if (arraysEqual(recievedAttributes, expectedAttributes)) {
|
||||||
// console.log("PASS: Recieved Attributes matched Expected Attributes");
|
// console.log("PASS: Recieved Attributes matched Expected Attributes");
|
||||||
done();
|
done();
|
||||||
}else{
|
} else {
|
||||||
console.error("FAIL", test, testObj.description);
|
console.error("FAIL", test, testObj.description);
|
||||||
console.error("FAIL: Recieved Attributes did not match Expected Attributes\nRecieved: ", recievedAttributes, "\nExpected: ", expectedAttributes)
|
console.error("FAIL: Recieved Attributes did not match Expected Attributes\nRecieved: ", recievedAttributes, "\nExpected: ", expectedAttributes)
|
||||||
console.error("FAILING HTML", testObj.html);
|
console.error("FAILING HTML", testObj.html);
|
||||||
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,7 +89,11 @@ const handshake = async (socket, padID) => {
|
||||||
return msg;
|
return msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('socket.io access checks', function() {
|
describe(__filename, function() {
|
||||||
|
let agent;
|
||||||
|
before(async function() { agent = await common.init(); });
|
||||||
|
|
||||||
|
describe('socket.io access checks', function() {
|
||||||
let authorize;
|
let authorize;
|
||||||
let authorizeHooksBackup;
|
let authorizeHooksBackup;
|
||||||
const cleanUpPads = async () => {
|
const cleanUpPads = async () => {
|
||||||
|
@ -352,4 +353,5 @@ describe('socket.io access checks', function() {
|
||||||
assert.equal(message.accessStatus, 'deny');
|
assert.equal(message.accessStatus, 'deny');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,11 +5,11 @@ 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'));
|
||||||
|
|
||||||
let agent;
|
describe(__filename, function() {
|
||||||
|
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() {
|
|
||||||
const backup = {};
|
const backup = {};
|
||||||
|
|
||||||
before(async function() {
|
before(async function() {
|
||||||
|
@ -79,9 +79,9 @@ describe('webaccess: without plugins', function() {
|
||||||
settings.requireAuthorization = true;
|
settings.requireAuthorization = true;
|
||||||
await agent.get('/admin/').auth('admin', 'admin-password').expect(200);
|
await agent.get('/admin/').auth('admin', 'admin-password').expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('webaccess: preAuthorize, authenticate, and authorize hooks', function() {
|
describe('webaccess: preAuthorize, authenticate, and authorize hooks', function() {
|
||||||
let callOrder;
|
let callOrder;
|
||||||
const Handler = class {
|
const Handler = class {
|
||||||
constructor(hookName, suffix) {
|
constructor(hookName, suffix) {
|
||||||
|
@ -333,9 +333,9 @@ describe('webaccess: preAuthorize, authenticate, and authorize hooks', function(
|
||||||
'authorize_0']);
|
'authorize_0']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('webaccess: authnFailure, authzFailure, authFailure hooks', function() {
|
describe('webaccess: authnFailure, authzFailure, authFailure hooks', function() {
|
||||||
const Handler = class {
|
const Handler = class {
|
||||||
constructor(hookName) {
|
constructor(hookName) {
|
||||||
this.hookName = hookName;
|
this.hookName = hookName;
|
||||||
|
@ -441,4 +441,5 @@ describe('webaccess: authnFailure, authzFailure, authFailure hooks', function()
|
||||||
assert(handlers['authzFailure'].called);
|
assert(handlers['authzFailure'].called);
|
||||||
assert(!handlers['authFailure'].called);
|
assert(!handlers['authFailure'].called);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue