31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { TeamCreatedAt } from './TeamCreatedAt';
|
|
|
|
describe('TeamCreatedAt', () => {
|
|
it('should create team created at', () => {
|
|
const date = new Date('2023-01-01');
|
|
const created = TeamCreatedAt.create(date);
|
|
expect(created.toDate()).toEqual(date);
|
|
expect(created.props).toEqual(date);
|
|
});
|
|
|
|
it('should throw for future date', () => {
|
|
const future = new Date();
|
|
future.setFullYear(future.getFullYear() + 1);
|
|
expect(() => TeamCreatedAt.create(future)).toThrow('Created date cannot be in the future');
|
|
});
|
|
|
|
it('should equal same dates', () => {
|
|
const date1 = new Date('2023-01-01');
|
|
const date2 = new Date('2023-01-01');
|
|
const c1 = TeamCreatedAt.create(date1);
|
|
const c2 = TeamCreatedAt.create(date2);
|
|
expect(c1.equals(c2)).toBe(true);
|
|
});
|
|
|
|
it('should not equal different dates', () => {
|
|
const c1 = TeamCreatedAt.create(new Date('2023-01-01'));
|
|
const c2 = TeamCreatedAt.create(new Date('2023-01-02'));
|
|
expect(c1.equals(c2)).toBe(false);
|
|
});
|
|
}); |