-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from Open-Cap-Stack/feature/financial-control…
…ler-api Fix update financial report functionality and tests
- Loading branch information
Showing
25 changed files
with
1,735 additions
and
980 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
const { connectDB, disconnectDB } = require('../db'); | ||
const app = require('../app'); | ||
// __tests__/setup/test-app.js | ||
const express = require('express'); | ||
const mongoose = require('mongoose'); | ||
const financialReportingRoutes = require('../../routes/financialReportingRoutes'); | ||
|
||
let server; | ||
const app = express(); | ||
|
||
beforeAll(async () => { | ||
await connectDB(); | ||
server = app.listen(5001); | ||
}); | ||
// Middleware | ||
app.use(express.json()); | ||
|
||
afterAll(async () => { | ||
await server.close(); | ||
await disconnectDB(); | ||
}); | ||
// Routes - match the path from your main app.js | ||
app.use('/api/financial-reports', financialReportingRoutes); | ||
|
||
describe('App Tests', () => { | ||
it('should run the server', async () => { | ||
expect(server).toBeDefined(); | ||
// Error handling middleware - match your main app.js format | ||
app.use((err, req, res, next) => { | ||
console.error('Error:', err.message); | ||
res.status(err.statusCode || 500).json({ | ||
error: err.message || 'Internal Server Error', | ||
}); | ||
}); | ||
|
||
module.exports = app; |
Oops, something went wrong.