mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
tests: Use the supertest agent from common.js
for backend tests
This commit is contained in:
parent
5a91cf1b49
commit
7dae5e3db8
10 changed files with 139 additions and 189 deletions
|
@ -6,21 +6,20 @@
|
|||
* Section "GLOBAL FUNCTIONS" in src/node/db/API.js
|
||||
*/
|
||||
const common = require('../../common');
|
||||
const settings = require('../../../../node/utils/Settings');
|
||||
const supertest = require('supertest');
|
||||
|
||||
const api = supertest(`http://${settings.ip}:${settings.port}`);
|
||||
|
||||
let agent;
|
||||
const apiKey = common.apiKey;
|
||||
const apiVersion = '1.2.14';
|
||||
|
||||
const endPoint = (point, version) => `/api/${version || apiVersion}/${point}?apikey=${apiKey}`;
|
||||
|
||||
describe(__filename, function () {
|
||||
before(async function () { agent = await common.init(); });
|
||||
|
||||
describe('Connectivity for instance-level API tests', function () {
|
||||
it('can connect', function (done) {
|
||||
this.timeout(150);
|
||||
api.get('/api/')
|
||||
agent.get('/api/')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200, done);
|
||||
});
|
||||
|
@ -29,7 +28,7 @@ describe(__filename, function () {
|
|||
describe('getStats', function () {
|
||||
it('Gets the stats of a running instance', function (done) {
|
||||
this.timeout(100);
|
||||
api.get(endPoint('getStats'))
|
||||
agent.get(endPoint('getStats'))
|
||||
.expect((res) => {
|
||||
if (res.body.code !== 0) throw new Error('getStats() failed');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue