helpyourneighbour/backend/tests/roles.test.js

14 lines
515 B
JavaScript
Raw Normal View History

const request = require('supertest');
const app = require('../src/server.js');
describe('Role Middleware Tests', () => {
test('should allow access to public route without authentication', async () => {
const response = await request(app).get('/health');
expect(response.status).toBe(200);
});
test('should deny access to protected route without authentication', async () => {
const response = await request(app).get('/test-role');
expect(response.status).toBe(401); // Unauthorized
});
});