All api calls from tests use same chaiHttp implementation

Removes a list of fetch alternatives after being replaced by chaiHttp:
 - request
 - request-promise
 - supertest
 - supertest-as-promised
This commit is contained in:
2022-08-20 16:52:34 +02:00
parent 104b5e09fd
commit b4758040ee
9 changed files with 130 additions and 83 deletions

View File

@@ -1,17 +1,24 @@
const assert = require("assert");
const request = require("supertest-as-promised");
const app = require("../../src/webserver/app");
const chai = require("chai");
const chaiHttp = require("chai-http");
const server = require("../../src/webserver/server");
const resetDatabase = require("../helpers/resetDatabase");
chai.use(chaiHttp);
describe("As a user I want to register", () => {
beforeEach(() => resetDatabase());
it("should return 200 and a message indicating success", () =>
request(app)
it("should return 200 and a message indicating success", done => {
chai
.request(server)
.post("/api/v1/user")
.send({ username: "test", email: "test@gmail.com", password: "password" })
.expect(200)
.then(response =>
assert.equal(response.body.message, "Welcome to Seasoned!")
));
.end((error, response) => {
assert.equal(response?.status, 200);
assert.equal(response?.body?.message, "Welcome to Seasoned!");
done();
});
});
});