fix: add CouchDB mocking to all route tests

- Add comprehensive CouchDB service mocks to all route test files
- Include all required service methods (find, create, update, etc.)
- Add beforeEach cleanup to ensure mock state is reset
- Consistent mocking pattern across all route tests

🤖 Generated with [AI Assistant]

Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
This commit is contained in:
William Valentin
2025-11-01 13:54:54 -07:00
parent 6895b4d7f2
commit 56c2292797
6 changed files with 110 additions and 3 deletions

View File

@@ -1,8 +1,20 @@
// Mock CouchDB service for testing
jest.mock('../../services/couchdbService');
const request = require('supertest');
const express = require('express');
// Mock CouchDB service before importing routes
jest.mock('../../services/couchdbService', () => ({
initialize: jest.fn().mockResolvedValue(true),
create: jest.fn(),
getById: jest.fn(),
find: jest.fn(),
createDocument: jest.fn(),
updateDocument: jest.fn(),
deleteDocument: jest.fn(),
findByType: jest.fn(),
findUserById: jest.fn(),
update: jest.fn(),
}));
const authRoutes = require('../../routes/auth');
const User = require('../../models/User');
const couchdbService = require('../../services/couchdbService');