import 'package:flutter_test/flutter_test.dart'; import 'package:sd_kovinar/models/holiday_theme.dart'; import 'package:sd_kovinar/models/target_style.dart'; void main() { String? on(int y, int m, int d) => HolidayTheme.on(DateTime(y, m, d))?.name; test('Easter Sunday', () { expect(HolidayTheme.easterSunday(2024), DateTime(2024, 3, 31)); expect(HolidayTheme.easterSunday(2025), DateTime(2025, 4, 20)); expect(HolidayTheme.easterSunday(2026), DateTime(2026, 4, 5)); expect(HolidayTheme.easterSunday(2027), DateTime(2027, 3, 28)); }); test('windows, inclusive, across the new year', () { expect(on(2026, 11, 30), isNull); expect(on(2026, 12, 1), 'Božič'); expect(on(2026, 12, 26), 'Božič'); expect(on(2026, 12, 27), 'Novo leto'); expect(on(2027, 1, 2), 'Novo leto'); expect(on(2027, 1, 3), isNull); expect(on(2026, 6, 23), 'Kresna noč'); expect(on(2026, 6, 24), 'Dan državnosti'); expect(on(2026, 10, 31), 'Noč čarovnic'); expect(on(2026, 11, 11), 'Martinovo'); expect(on(2026, 11, 27), isNull); }); test('Easter-based holidays', () { // 2026: Easter 5. 4., Shrove Tuesday 17. 2. expect(on(2026, 2, 17), 'Pust'); expect(on(2026, 2, 12), 'Valentinovo'); // first in the list wins over Pust (-52 = 12. 2.) expect(on(2026, 3, 29), 'Velika noč'); expect(on(2026, 4, 6), 'Velika noč'); expect(on(2026, 4, 7), isNull); }); test('Easter windows in calendar days, across the clock change', () { final easter = HolidayTheme.all.firstWhere((h) => h.name == 'Velika noč'); expect(easter.window(DateTime(2026, 4, 1)), (DateTime(2026, 3, 29), DateTime(2026, 4, 6))); expect(on(2026, 3, 28), isNull); // the day before the window final pust = HolidayTheme.all.firstWhere((h) => h.name == 'Pust'); expect(pust.window(DateTime(2026, 2, 17)).$2, DateTime(2026, 2, 18)); }); test('every holiday has its target and the window of a date around new year', () { for (final h in HolidayTheme.all) { expect(TargetStyle.byId(h.targetId).id, h.targetId); } final newYear = HolidayTheme.all.firstWhere((h) => h.name == 'Novo leto'); expect(newYear.window(DateTime(2027, 1, 1)), (DateTime(2026, 12, 27), DateTime(2027, 1, 2))); expect(newYear.window(DateTime(2026, 12, 30)), (DateTime(2026, 12, 27), DateTime(2027, 1, 2))); }); }