Initial commit: Complete NodeJS-native setup

- Migrated from Python pre-commit to NodeJS-native solution
- Reorganized documentation structure
- Set up Husky + lint-staged for efficient pre-commit hooks
- Fixed Dockerfile healthcheck issue
- Added comprehensive documentation index
This commit is contained in:
William Valentin
2025-09-06 01:42:48 -07:00
commit e48adbcb00
159 changed files with 24405 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
import { EmailVerificationService } from '../emailVerification.service';
import { dbService } from '../../couchdb.factory';
jest.mock('../../couchdb.factory');
jest.mock('../../email');
describe('EmailVerificationService', () => {
let emailVerificationService: EmailVerificationService;
beforeEach(() => {
emailVerificationService = new EmailVerificationService();
});
test('should generate and validate verification token', async () => {
const user = {
_id: 'user1',
email: 'test@example.com',
username: 'testuser',
password: 'password',
};
const verificationToken =
await emailVerificationService.generateVerificationToken(user as any);
expect(verificationToken).toBeDefined();
expect(verificationToken.token).toBeDefined();
expect(verificationToken.expiresAt).toBeDefined();
const validatedUser =
await emailVerificationService.validateVerificationToken(
verificationToken.token
);
expect(validatedUser).toBeDefined();
expect(validatedUser!._id).toBe(user._id);
});
test('should not validate expired token', async () => {
const user = {
_id: 'user2',
email: 'test2@example.com',
username: 'testuser2',
password: 'password2',
};
const verificationToken =
await emailVerificationService.generateVerificationToken(user as any);
// Set expiresAt to past date
verificationToken.expiresAt = new Date(Date.now() - 1000 * 60 * 60 * 24);
const validatedUser =
await emailVerificationService.validateVerificationToken(
verificationToken.token
);
expect(validatedUser).toBeNull();
});
});