fix database connect

This commit is contained in:
Simon Larsen 2023-09-21 20:58:20 +01:00
parent 18461d58d6
commit fed9ab4621
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE

View File

@ -23,15 +23,7 @@ type ObjectIdOrNull = ObjectID | null;
describe('ProjectMiddleware', () => { describe('ProjectMiddleware', () => {
const mockedObjectId: ObjectID = ObjectID.generate(); const mockedObjectId: ObjectID = ObjectID.generate();
let database!: Database;
beforeEach(async () => {
database = new Database();
await database.createAndConnect();
});
afterEach(async () => {
await database.disconnectAndDropDatabase();
});
describe('getProjectId', () => { describe('getProjectId', () => {
describe("should return value when tenantid is passed in the request's", () => { describe("should return value when tenantid is passed in the request's", () => {
@ -164,8 +156,16 @@ describe('ProjectMiddleware', () => {
id: mockedObjectId, id: mockedObjectId,
} as ApiKey; } as ApiKey;
beforeEach(() => { let database!: Database;
beforeEach(async () => {
next = jest.fn(); next = jest.fn();
database = new Database();
await database.createAndConnect();
});
afterEach(async () => {
await database.disconnectAndDropDatabase();
}); });
beforeAll(() => { beforeAll(() => {
@ -189,7 +189,7 @@ describe('ProjectMiddleware', () => {
); );
expect(next).toHaveBeenCalledWith( expect(next).toHaveBeenCalledWith(
new BadDataException('ProjectId not found in the request') new BadDataException('ProjectID not found in the request header.')
); );
expect(spyGetProjectId).toHaveBeenCalledWith(req); expect(spyGetProjectId).toHaveBeenCalledWith(req);