0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-03-22 06:48:11 +00:00

Merge pull request #4571 from G-Ambatte/fixLocalAdminAPITests

Fix Admin API tests
This commit is contained in:
Trevor Buckner
2026-02-16 20:57:15 -05:00
committed by GitHub

View File

@@ -1,4 +1,5 @@
/*eslint max-lines: ["warn", {"max": 1000, "skipBlankLines": true, "skipComments": true}]*/
import mongoose from 'mongoose';
import supertest from 'supertest';
import HBApp from './app.js';
import { model as NotificationModel } from './notifications.model.js';
@@ -8,8 +9,19 @@ import { model as HomebrewModel } from './homebrew.model.js';
// Mimic https responses to avoid being redirected all the time
const app = supertest.agent(HBApp).set('X-Forwarded-Proto', 'https');
let dbState;
describe('Tests for admin api', ()=>{
beforeEach(()=>{
// Mock DB ready (for dbCheck middleware)
dbState = mongoose.connection.readyState;
mongoose.connection.readyState = 1;
});
afterEach(()=>{
// Restore DB ready state
mongoose.connection.readyState = dbState;
jest.resetAllMocks();
});