core tests

This commit is contained in:
2026-01-22 18:05:30 +01:00
parent 0a37454171
commit 35cc7cf12b
26 changed files with 4701 additions and 21 deletions

View File

@@ -0,0 +1,58 @@
import { describe, expect, it } from 'vitest';
import { NotificationDomainError } from './NotificationDomainError';
describe('NotificationDomainError', () => {
it('creates an error with default validation kind', () => {
const error = new NotificationDomainError('Invalid notification data');
expect(error.name).toBe('NotificationDomainError');
expect(error.type).toBe('domain');
expect(error.context).toBe('notifications');
expect(error.kind).toBe('validation');
expect(error.message).toBe('Invalid notification data');
});
it('creates an error with custom kind', () => {
const error = new NotificationDomainError('Notification not found', 'not_found');
expect(error.kind).toBe('not_found');
expect(error.message).toBe('Notification not found');
});
it('creates an error with business rule kind', () => {
const error = new NotificationDomainError('Cannot send notification during quiet hours', 'business_rule');
expect(error.kind).toBe('business_rule');
expect(error.message).toBe('Cannot send notification during quiet hours');
});
it('creates an error with conflict kind', () => {
const error = new NotificationDomainError('Notification already read', 'conflict');
expect(error.kind).toBe('conflict');
expect(error.message).toBe('Notification already read');
});
it('creates an error with unauthorized kind', () => {
const error = new NotificationDomainError('Cannot access notification', 'unauthorized');
expect(error.kind).toBe('unauthorized');
expect(error.message).toBe('Cannot access notification');
});
it('inherits from Error', () => {
const error = new NotificationDomainError('Test error');
expect(error).toBeInstanceOf(Error);
expect(error.stack).toBeDefined();
});
it('has correct error properties', () => {
const error = new NotificationDomainError('Test error', 'validation');
expect(error.name).toBe('NotificationDomainError');
expect(error.type).toBe('domain');
expect(error.context).toBe('notifications');
expect(error.kind).toBe('validation');
});
});