fix: resolve email verification service test failures
- Fix missing imports and dependencies in email verification tests - Update email verification service implementation - Resolve test reference errors that were causing failures - Improve error handling and test reliability This fixes the 3 failing database service tests mentioned in the improvement summary.
This commit is contained in:
@@ -10,9 +10,9 @@ jest.mock('../../mailgun.service', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock the couchdb.factory service
|
||||
jest.mock('../../couchdb.factory', () => ({
|
||||
dbService: {
|
||||
// Mock the database service
|
||||
jest.mock('../../database', () => ({
|
||||
databaseService: {
|
||||
findUserByEmail: jest.fn(),
|
||||
updateUser: jest.fn(),
|
||||
},
|
||||
@@ -45,9 +45,9 @@ describe('EmailVerificationService', () => {
|
||||
|
||||
// Get mocked services
|
||||
const mailgunModule = await import('../../mailgun.service');
|
||||
const dbModule = await import('../../couchdb.factory');
|
||||
const dbModule = await import('../../database');
|
||||
mockMailgunService = mailgunModule.mailgunService;
|
||||
mockDbService = dbModule.dbService;
|
||||
mockDbService = dbModule.databaseService;
|
||||
});
|
||||
|
||||
describe('generateVerificationToken', () => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
import { EmailVerificationToken, AuthenticatedUser } from './auth.types';
|
||||
import { mailgunService } from '../mailgun.service';
|
||||
import { AccountStatus } from './auth.constants';
|
||||
import { dbService } from '../couchdb.factory';
|
||||
import { databaseService } from '../database';
|
||||
|
||||
const TOKEN_EXPIRY_HOURS = 24;
|
||||
|
||||
@@ -63,7 +63,7 @@ export class EmailVerificationService {
|
||||
}
|
||||
|
||||
// Find the user (in production, this would be a proper database lookup)
|
||||
const user = await dbService.findUserByEmail(verificationToken.email);
|
||||
const user = await databaseService.findUserByEmail(verificationToken.email);
|
||||
|
||||
return user as AuthenticatedUser;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ export class EmailVerificationService {
|
||||
status: AccountStatus.ACTIVE,
|
||||
};
|
||||
|
||||
await dbService.updateUser(updatedUser);
|
||||
await databaseService.updateUser(updatedUser);
|
||||
|
||||
// Remove used token
|
||||
const tokens = JSON.parse(
|
||||
|
||||
Reference in New Issue
Block a user