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,29 @@
const request = require("supertest-as-promised");
const app = require("../../src/webserver/app");
const assert = require("assert");
const chai = require("chai");
const chaiHttp = require("chai-http");
const server = require("../../src/webserver/server");
const resetDatabase = require("../helpers/resetDatabase");
const createCacheEntry = require("../helpers/createCacheEntry");
const interstellarQuerySuccess = require("../fixtures/interstellar-query-movie-success-response.json");
chai.use(chaiHttp);
describe("As an anonymous user I want to search for a movie", () => {
beforeEach(() => resetDatabase());
beforeEach(() =>
createCacheEntry("mos:1:interstellar", interstellarQuerySuccess)
createCacheEntry("tmdb/mos:1:interstellar:false", interstellarQuerySuccess)
);
it("should return 200 with the search results even if user is not logged in", () =>
request(app)
it("should return 200 with the search results even if user is not logged in", done => {
chai
.request(server)
.get("/api/v2/search/movie?query=interstellar&page=1")
.expect(200));
.end((error, response) => {
// console.log(response);
assert.equal(response?.status, 200);
done();
});
});
});