replace with custom superagent based on fetch API
This commit is contained in:
@@ -10,7 +10,7 @@ const constants = require('../constants.js'),
|
||||
expect = require('expect.js'),
|
||||
safe = require('safetydance'),
|
||||
server = require('../server.js'),
|
||||
superagent = require('superagent');
|
||||
superagent = require('../superagent.js');
|
||||
|
||||
const SERVER_URL = 'http://localhost:' + constants.PORT;
|
||||
|
||||
@@ -53,7 +53,7 @@ describe('Server', function () {
|
||||
expect(response.status).to.equal(404);
|
||||
|
||||
const response2 = await superagent.get(SERVER_URL + '/api/v1/cloudron/status');
|
||||
expect(response2.statusCode).to.equal(200);
|
||||
expect(response2.status).to.equal(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -63,7 +63,7 @@ describe('Server', function () {
|
||||
|
||||
it('config fails due missing token', async function () {
|
||||
const response = await superagent.get(SERVER_URL + '/api/v1/dashboard/config').ok(() => true);
|
||||
expect(response.statusCode).to.equal(401);
|
||||
expect(response.status).to.equal(401);
|
||||
});
|
||||
|
||||
it('config fails due wrong token', async function () {
|
||||
@@ -86,7 +86,7 @@ describe('Server', function () {
|
||||
after(server.stop);
|
||||
|
||||
it('responds to OPTIONS', async function () {
|
||||
const response = await superagent('OPTIONS', SERVER_URL + '/api/v1/cloudron/status')
|
||||
const response = await superagent.options(SERVER_URL + '/api/v1/cloudron/status')
|
||||
.set('Access-Control-Request-Method', 'GET')
|
||||
.set('Access-Control-Request-Headers', 'accept, origin, x-superagented-with')
|
||||
.set('Origin', 'http://localhost');
|
||||
@@ -98,7 +98,7 @@ describe('Server', function () {
|
||||
});
|
||||
|
||||
it('does not crash for malformed origin', async function () {
|
||||
const response = await superagent('OPTIONS', SERVER_URL + '/api/v1/cloudron/status')
|
||||
const response = await superagent.options(SERVER_URL + '/api/v1/cloudron/status')
|
||||
.set('Origin', 'foobar')
|
||||
.ok(() => true);
|
||||
expect(response.status).to.be(405);
|
||||
|
||||
Reference in New Issue
Block a user