tests: reorganize some files, because we are going to copy & paste them.
In the following commits Pierre is going to copy & modify some files. This commit prepares the source files in order to minimize those differences, so we can re-unify them as soon as possible. No functional changes.pull/3688/head
parent
5bcc5a3be0
commit
fe0cf4bdb0
|
@ -1,13 +1,15 @@
|
||||||
var jsonminify = require(__dirname+"/../../src/node_modules/jsonminify");
|
var jsonminify = require(__dirname+"/../../src/node_modules/jsonminify");
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
function loadSettings(){
|
function loadSettings(){
|
||||||
var settingsStr = fs.readFileSync(__dirname+"/../../settings.json").toString();
|
var settingsStr = fs.readFileSync(__dirname+"/../../settings.json").toString();
|
||||||
// try to parse the settings
|
// try to parse the settings
|
||||||
var settings;
|
|
||||||
try {
|
try {
|
||||||
if(settingsStr) {
|
if(settingsStr) {
|
||||||
settingsStr = jsonminify(settingsStr).replace(",]","]").replace(",}","}");
|
settingsStr = jsonminify(settingsStr).replace(",]","]").replace(",}","}");
|
||||||
return JSON.parse(settingsStr);
|
var settings = JSON.parse(settingsStr);
|
||||||
|
|
||||||
|
return settings;
|
||||||
}
|
}
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.error("whoops something is bad with settings");
|
console.error("whoops something is bad with settings");
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
var assert = require('assert')
|
const assert = require('assert');
|
||||||
supertest = require(__dirname+'/../../../../src/node_modules/supertest'),
|
const supertest = require(__dirname+'/../../../../src/node_modules/supertest');
|
||||||
fs = require('fs'),
|
const fs = require('fs');
|
||||||
settings = require(__dirname+'/../../loadSettings').loadSettings(),
|
const settings = require(__dirname+'/../../loadSettings').loadSettings();
|
||||||
api = supertest('http://'+settings.ip+":"+settings.port),
|
const api = supertest('http://'+settings.ip+":"+settings.port);
|
||||||
path = require('path'),
|
const path = require('path');
|
||||||
async = require(__dirname+'/../../../../src/node_modules/async');
|
const async = require(__dirname+'/../../../../src/node_modules/async');
|
||||||
|
|
||||||
var filePath = path.join(__dirname, '../../../../APIKEY.txt');
|
var filePath = path.join(__dirname, '../../../../APIKEY.txt');
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ var ulHtml = '<!doctype html><html><body><ul class="bullet"><li>one</li><li>two<
|
||||||
var expectedHtml = '<!doctype html><html><body><ul class="bullet"><li>one</li><li>two</li><li>0</li><li>1</li><li>2<ul class="bullet"><li>3</li><li>4</ul></li></ul><ol class="number"><li>item<ol class="number"><li>item1</li><li>item2</ol></li></ol></body></html>';
|
var expectedHtml = '<!doctype html><html><body><ul class="bullet"><li>one</li><li>two</li><li>0</li><li>1</li><li>2<ul class="bullet"><li>3</li><li>4</ul></li></ul><ol class="number"><li>item<ol class="number"><li>item1</li><li>item2</ol></li></ol></body></html>';
|
||||||
|
|
||||||
describe('Connectivity', function(){
|
describe('Connectivity', function(){
|
||||||
it('errors if can not 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)
|
||||||
|
@ -37,7 +37,7 @@ describe('Connectivity', function(){
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('API Versioning', function(){
|
describe('API Versioning', function(){
|
||||||
it('errors if can not connect', function(done) {
|
it('finds the version tag', function(done) {
|
||||||
api.get('/api/')
|
api.get('/api/')
|
||||||
.expect(function(res){
|
.expect(function(res){
|
||||||
apiVersion = res.body.currentVersion;
|
apiVersion = res.body.currentVersion;
|
||||||
|
@ -49,7 +49,7 @@ describe('API Versioning', function(){
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Permission', function(){
|
describe('Permission', function(){
|
||||||
it('errors if can connect without correct 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
|
||||||
var permErrorURL = '/api/'+apiVersion+'/createPad?apikey=password&padID=test';
|
var permErrorURL = '/api/'+apiVersion+'/createPad?apikey=password&padID=test';
|
||||||
|
|
Loading…
Reference in New Issue