UNPKG

kenat

Version:

A JavaScript library for the Ethiopian calendar with date and time support.

64 lines (52 loc) 3 kB
import { getFastingPeriod } from '../src/fasting.js'; // Mock dependencies if they are not available in the test environment // For this example, we assume the underlying functions are correct. describe('getFastingPeriod', () => { describe('Christian Fasts for 2016 E.C.', () => { const year = 2016; test('should return the correct start and end dates for The Great Lent (Abiy Tsome)', () => { const period = getFastingPeriod('ABIY_TSOME', year); // VERIFIED: In 2016, Abiy Tsome starts on Megabit 2 and ends on Siklet (Miazia 25) expect(period.start).toEqual({ year: 2016, month: 7, day: 2 }); expect(period.end).toEqual({ year: 2016, month: 8, day: 25 }); }); test('should return the correct start and end dates for Fast of the Apostles (Tsome Hawaryat)', () => { const period = getFastingPeriod('TSOME_HAWARYAT', year); // VERIFIED: In 2016, Paraclete is Sene 17, so Tsome Hawaryat starts Sene 18. It ends on Hamle 4. expect(period.end).toEqual({ year: 2016, month: 11, day: 4 }); }); test('should return the correct start and end dates for Fast of Nineveh', () => { const period = getFastingPeriod('NINEVEH', year); // VERIFIED: In 2016, Nineveh starts on Yekatit 18 and lasts 3 days. expect(period.start).toEqual({ year: 2016, month: 6, day: 18 }); expect(period.end).toEqual({ year: 2016, month: 6, day: 20 }); }); test('should return the correct start and end dates for Fast of the Prophets (Tsome Nebiyat)', () => { const period = getFastingPeriod('TSOME_NEBIYAT', year); // This is a fixed fast from Hidar 15 to Tahsas 28. This test was already correct. expect(period.start).toEqual({ year: 2016, month: 3, day: 15 }); expect(period.end).toEqual({ year: 2016, month: 4, day: 28 }); }); }); describe('Muslim Fasts for 2016 E.C.', () => { const year = 2016; test('should return the correct start and end dates for Ramadan', () => { const period = getFastingPeriod('RAMADAN', year); // VERIFIED: For 2016 E.C., Ramadan 1445 A.H. runs from Megabit 2 to Miazia 1. expect(period.start).toEqual({ year: 2016, month: 7, day: 2 }); }); }); describe('Error and Edge Case Handling', () => { test('should return null for an unknown fast key', () => { const period = getFastingPeriod('UNKNOWN_FAST_KEY', 2016); expect(period).toBeNull(); }); test('should return a valid period for a future year', () => { // This confirms the calculation logic doesn't crash on different inputs. const period = getFastingPeriod('ABIY_TSOME', 2020); expect(period).toBeDefined(); expect(period.start).toBeDefined(); expect(period.end).toBeDefined(); }); }); });