wip
This commit is contained in:
29
tests/unit/analytics/domain/value-objects/PageViewId.test.ts
Normal file
29
tests/unit/analytics/domain/value-objects/PageViewId.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { PageViewId } from '../../../../../packages/analytics/domain/value-objects/PageViewId';
|
||||
|
||||
describe('PageViewId', () => {
|
||||
it('creates a valid PageViewId from a non-empty string', () => {
|
||||
const id = PageViewId.create('pv_123');
|
||||
|
||||
expect(id.value).toBe('pv_123');
|
||||
});
|
||||
|
||||
it('trims whitespace from the raw value', () => {
|
||||
const id = PageViewId.create(' pv_456 ');
|
||||
|
||||
expect(id.value).toBe('pv_456');
|
||||
});
|
||||
|
||||
it('throws for empty or whitespace-only strings', () => {
|
||||
expect(() => PageViewId.create('')).toThrow(Error);
|
||||
expect(() => PageViewId.create(' ')).toThrow(Error);
|
||||
});
|
||||
|
||||
it('compares equality based on underlying value', () => {
|
||||
const a = PageViewId.create('pv_1');
|
||||
const b = PageViewId.create('pv_1');
|
||||
const c = PageViewId.create('pv_2');
|
||||
|
||||
expect(a.equals(b)).toBe(true);
|
||||
expect(a.equals(c)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user