test: migrate from Jest to Vitest (Phase 1 complete)
- Remove Jest and all related packages - Install Vitest with coverage support - Create vitest.config.ts with path aliases - Set up global test configuration - Migrate all 6 test files to Vitest syntax - Update TypeScript configuration for better Vitest support - Create separate tsconfig.build.json for clean builds - Fix all import/module issues in tests - All 68 tests passing successfully - Current coverage baseline: 2.45% Phase 1 of testing suite improvement complete. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { AuthManager } from '../src/utils/auth';
|
||||
|
||||
describe('AuthManager', () => {
|
||||
@@ -28,7 +29,7 @@ describe('AuthManager', () => {
|
||||
});
|
||||
|
||||
it('should reject expired tokens', () => {
|
||||
jest.useFakeTimers();
|
||||
vi.useFakeTimers();
|
||||
|
||||
const token = authManager.generateToken(1); // 1 hour expiry
|
||||
|
||||
@@ -36,12 +37,12 @@ describe('AuthManager', () => {
|
||||
expect(authManager.validateToken(token, 'expected-token')).toBe(true);
|
||||
|
||||
// Fast forward 2 hours
|
||||
jest.advanceTimersByTime(2 * 60 * 60 * 1000);
|
||||
vi.advanceTimersByTime(2 * 60 * 60 * 1000);
|
||||
|
||||
// Token should be expired
|
||||
expect(authManager.validateToken(token, 'expected-token')).toBe(false);
|
||||
|
||||
jest.useRealTimers();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -55,19 +56,19 @@ describe('AuthManager', () => {
|
||||
});
|
||||
|
||||
it('should set custom expiry time', () => {
|
||||
jest.useFakeTimers();
|
||||
vi.useFakeTimers();
|
||||
|
||||
const token = authManager.generateToken(24); // 24 hours
|
||||
|
||||
// Token should be valid after 23 hours
|
||||
jest.advanceTimersByTime(23 * 60 * 60 * 1000);
|
||||
vi.advanceTimersByTime(23 * 60 * 60 * 1000);
|
||||
expect(authManager.validateToken(token, 'expected')).toBe(true);
|
||||
|
||||
// Token should expire after 25 hours
|
||||
jest.advanceTimersByTime(2 * 60 * 60 * 1000);
|
||||
vi.advanceTimersByTime(2 * 60 * 60 * 1000);
|
||||
expect(authManager.validateToken(token, 'expected')).toBe(false);
|
||||
|
||||
jest.useRealTimers();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user