Add simple test with Mocha

This commit is contained in:
Adolfo Reyna
2025-02-21 22:06:45 -05:00
parent 2e7c0a6915
commit ad62814d82
4 changed files with 3180 additions and 3 deletions

View File

@@ -67,7 +67,7 @@ DB.getDB.then((DB) => {
app.get('/', sessionChecker, async (req, res) => {
try {
const userInfo = req.userInfo;
if(!userInfo) {
if (!userInfo) {
// This should not happend, since the sessionChecker should redirect to login
return res.status(401).json({ status: "Unauthorized" });
}
@@ -146,7 +146,7 @@ DB.getDB.then((DB) => {
app.post('/token/', sessionChecker, async (req, res) => {
try {
const profileid = getProfileId(req);
const { token } = req.body;
const { token } = req.body;
// Validate token presence
if (!token) {
return res.status(400).json({ status: 'Token is required' });
@@ -186,3 +186,5 @@ DB.getDB.then((DB) => {
throw err;
});
// Export the app for testing purposes
module.exports = { app, mongoDB: DB };