refactor mylistings and my rentals
This commit is contained in:
@@ -66,7 +66,7 @@ describe('Rentals Routes', () => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('GET /my-rentals', () => {
|
||||
describe('GET /renting', () => {
|
||||
it('should get rentals for authenticated user', async () => {
|
||||
const mockRentals = [
|
||||
{
|
||||
@@ -86,7 +86,7 @@ describe('Rentals Routes', () => {
|
||||
mockRentalFindAll.mockResolvedValue(mockRentals);
|
||||
|
||||
const response = await request(app)
|
||||
.get('/rentals/my-rentals');
|
||||
.get('/rentals/renting');
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.body).toEqual(mockRentals);
|
||||
@@ -108,14 +108,14 @@ describe('Rentals Routes', () => {
|
||||
mockRentalFindAll.mockRejectedValue(new Error('Database error'));
|
||||
|
||||
const response = await request(app)
|
||||
.get('/rentals/my-rentals');
|
||||
.get('/rentals/renting');
|
||||
|
||||
expect(response.status).toBe(500);
|
||||
expect(response.body).toEqual({ error: 'Failed to fetch rentals' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /my-listings', () => {
|
||||
describe('GET /owning', () => {
|
||||
it('should get listings for authenticated user', async () => {
|
||||
const mockListings = [
|
||||
{
|
||||
@@ -129,7 +129,7 @@ describe('Rentals Routes', () => {
|
||||
mockRentalFindAll.mockResolvedValue(mockListings);
|
||||
|
||||
const response = await request(app)
|
||||
.get('/rentals/my-listings');
|
||||
.get('/rentals/owning');
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.body).toEqual(mockListings);
|
||||
@@ -151,7 +151,7 @@ describe('Rentals Routes', () => {
|
||||
mockRentalFindAll.mockRejectedValue(new Error('Database error'));
|
||||
|
||||
const response = await request(app)
|
||||
.get('/rentals/my-listings');
|
||||
.get('/rentals/owning');
|
||||
|
||||
expect(response.status).toBe(500);
|
||||
expect(response.body).toEqual({ error: 'Failed to fetch listings' });
|
||||
|
||||
Reference in New Issue
Block a user