fix: arreglar mocking en tests de validación de usuario

Co-authored-by: aider (openrouter/x-ai/grok-code-fast-1) <aider@aider.chat>
pull/1/head
borja 2 months ago
parent 1846491c07
commit d898cd2500

@ -523,20 +523,26 @@ describe('WebhookServer', () => {
describe('User validation in handleMessageUpsert', () => {
let mockEnsureUserExists: any;
let consoleSpy: any;
let originalConsoleLog: any;
beforeEach(async () => {
mockEnsureUserExists = mock(() => '1234567890');
// Mock the function in the module
const dbModule = await import('../../src/db');
dbModule.ensureUserExists = mockEnsureUserExists;
// Mock the db module to replace ensureUserExists
mock.module('../../src/db', () => ({
db: {},
getDb: () => ({}),
initializeDatabase: () => {},
ensureUserExists: mockEnsureUserExists
}));
originalConsoleLog = console.log;
consoleSpy = mock(() => {});
console.log = consoleSpy;
});
afterEach(() => {
mockEnsureUserExists.mockRestore();
consoleSpy.mockRestore();
console.log = originalConsoleLog;
});
test('should proceed with valid user', async () => {

Loading…
Cancel
Save