Add user database service and unit tests
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 4m28s

- Implement user database service with functions for user management (create, find, update, delete).
- Add comprehensive unit tests for user database service using Vitest.
- Mock database interactions to ensure isolated testing.
- Create setup files for unit tests to handle database connections and global mocks.
- Introduce error handling for unique constraints and foreign key violations.
- Enhance logging for better traceability during database operations.
This commit is contained in:
2025-12-04 15:30:27 -08:00
parent 4cf587c8f0
commit 80d2b1ffe6
62 changed files with 135 additions and 136 deletions

View File

@@ -1,12 +1,12 @@
// src/services/backgroundJobService.test.ts
import { describe, it, expect, vi, beforeEach, type Mocked } from 'vitest';
import cron from 'node-cron';
import * as db from './db';
import * as db from './db/index.db';
import { logger } from './logger.server';
import { sendDealNotificationEmail } from './emailService.server';
import { runDailyDealCheck, startBackgroundJobs } from './backgroundJobService';
import { WatchedItemDeal } from '../types';
import { AdminUserView } from './db/admin';
import { AdminUserView } from './db/admin.db';
// Mock dependencies
vi.mock('node-cron');