This commit is contained in:
2025-12-17 00:33:13 +01:00
parent 8c67081953
commit f01e01e50c
186 changed files with 9242 additions and 1342 deletions

View File

@@ -0,0 +1,38 @@
import { describe, it, expect } from 'vitest';
import { JoinedAt } from './JoinedAt';
describe('JoinedAt', () => {
it('should create a joined date', () => {
const past = new Date('2020-01-01');
const joined = JoinedAt.create(past);
expect(joined.toDate()).toEqual(past);
});
it('should throw on future date', () => {
const future = new Date();
future.setFullYear(future.getFullYear() + 1);
expect(() => JoinedAt.create(future)).toThrow('Joined date cannot be in the future');
});
it('should allow current date', () => {
const now = new Date();
const joined = JoinedAt.create(now);
expect(joined.toDate().getTime()).toBeCloseTo(now.getTime(), -3); // close enough
});
it('should equal same date', () => {
const d1 = new Date('2020-01-01');
const d2 = new Date('2020-01-01');
const j1 = JoinedAt.create(d1);
const j2 = JoinedAt.create(d2);
expect(j1.equals(j2)).toBe(true);
});
it('should not equal different date', () => {
const d1 = new Date('2020-01-01');
const d2 = new Date('2020-01-02');
const j1 = JoinedAt.create(d1);
const j2 = JoinedAt.create(d2);
expect(j1.equals(j2)).toBe(false);
});
});