resolve todos in website
This commit is contained in:
51
core/notifications/domain/value-objects/QuietHours.test.ts
Normal file
51
core/notifications/domain/value-objects/QuietHours.test.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { QuietHours } from '../../../../../core/notifications/domain/value-objects/QuietHours';
|
||||
|
||||
describe('QuietHours', () => {
|
||||
it('creates a valid normal-range window', () => {
|
||||
const qh = QuietHours.create(9, 17);
|
||||
expect(qh.props.startHour).toBe(9);
|
||||
expect(qh.props.endHour).toBe(17);
|
||||
});
|
||||
|
||||
it('creates a valid overnight window', () => {
|
||||
const qh = QuietHours.create(22, 7);
|
||||
expect(qh.props.startHour).toBe(22);
|
||||
expect(qh.props.endHour).toBe(7);
|
||||
});
|
||||
|
||||
it('throws when hours are out of range', () => {
|
||||
expect(() => QuietHours.create(-1, 10)).toThrow();
|
||||
expect(() => QuietHours.create(0, 24)).toThrow();
|
||||
});
|
||||
|
||||
it('throws when start and end are equal', () => {
|
||||
expect(() => QuietHours.create(10, 10)).toThrow();
|
||||
});
|
||||
|
||||
it('detects containment for normal range', () => {
|
||||
const qh = QuietHours.create(9, 17);
|
||||
expect(qh.containsHour(8)).toBe(false);
|
||||
expect(qh.containsHour(9)).toBe(true);
|
||||
expect(qh.containsHour(12)).toBe(true);
|
||||
expect(qh.containsHour(17)).toBe(false);
|
||||
});
|
||||
|
||||
it('detects containment for overnight range', () => {
|
||||
const qh = QuietHours.create(22, 7);
|
||||
expect(qh.containsHour(21)).toBe(false);
|
||||
expect(qh.containsHour(22)).toBe(true);
|
||||
expect(qh.containsHour(23)).toBe(true);
|
||||
expect(qh.containsHour(0)).toBe(true);
|
||||
expect(qh.containsHour(6)).toBe(true);
|
||||
expect(qh.containsHour(7)).toBe(false);
|
||||
});
|
||||
|
||||
it('implements value-based equality', () => {
|
||||
const a = QuietHours.create(22, 7);
|
||||
const b = QuietHours.create(22, 7);
|
||||
const c = QuietHours.create(9, 17);
|
||||
|
||||
expect(a.equals(b)).toBe(true);
|
||||
expect(a.equals(c)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user