replace with custom superagent based on fetch API
This commit is contained in:
@@ -9,7 +9,7 @@ const archives = require('../../archives.js'),
|
||||
backups = require('../../backups.js'),
|
||||
common = require('./common.js'),
|
||||
expect = require('expect.js'),
|
||||
superagent = require('superagent');
|
||||
superagent = require('../../superagent.js');
|
||||
|
||||
describe('Archives API', function () {
|
||||
const { setup, cleanup, serverUrl, owner, auditSource } = common;
|
||||
@@ -42,7 +42,7 @@ describe('Archives API', function () {
|
||||
it('list succeeds', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/archives`)
|
||||
.query({ access_token: owner.token });
|
||||
expect(response.statusCode).to.equal(200);
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.body.archives.length).to.be(1);
|
||||
expect(response.body.archives[0].id).to.be(archiveId);
|
||||
expect(response.body.archives[0].appConfig).to.eql(appBackup.appConfig);
|
||||
@@ -52,7 +52,7 @@ describe('Archives API', function () {
|
||||
it('get valid archive', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/archives/${archiveId}`)
|
||||
.query({ access_token: owner.token });
|
||||
expect(response.statusCode).to.equal(200);
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.body.appConfig).to.eql(appBackup.appConfig);
|
||||
expect(response.body.manifest).to.eql(appBackup.manifest);
|
||||
});
|
||||
@@ -61,24 +61,24 @@ describe('Archives API', function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/archives/random`)
|
||||
.query({ access_token: owner.token })
|
||||
.ok(() => true);
|
||||
expect(response.statusCode).to.equal(404);
|
||||
expect(response.status).to.equal(404);
|
||||
});
|
||||
|
||||
it('cannot del invalid archive', async function () {
|
||||
const response = await superagent.del(`${serverUrl}/api/v1/archives/random`)
|
||||
.query({ access_token: owner.token })
|
||||
.ok(() => true);
|
||||
expect(response.statusCode).to.equal(404);
|
||||
expect(response.status).to.equal(404);
|
||||
});
|
||||
|
||||
it('del valid archive', async function () {
|
||||
const response = await superagent.del(`${serverUrl}/api/v1/archives/${archiveId}`)
|
||||
.query({ access_token: owner.token });
|
||||
expect(response.statusCode).to.equal(204);
|
||||
expect(response.status).to.equal(204);
|
||||
|
||||
const response2 = await superagent.get(`${serverUrl}/api/v1/archives`)
|
||||
.query({ access_token: owner.token });
|
||||
expect(response2.statusCode).to.equal(200);
|
||||
expect(response2.status).to.equal(200);
|
||||
expect(response2.body.archives.length).to.be(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user