-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcalendar_service_test.dart
More file actions
54 lines (45 loc) · 1.6 KB
/
calendar_service_test.dart
File metadata and controls
54 lines (45 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import 'package:flutter_test/flutter_test.dart';
import 'package:tattoo/services/calendar_service.dart';
import 'package:tattoo/services/portal_service.dart';
import '../test_helpers.dart';
void main() {
group('CalendarService Tests', () {
late PortalService portalService;
late CalendarService calendarService;
setUpAll(() {
TestCredentials.validate();
});
setUp(() async {
portalService = PortalService();
calendarService = CalendarService(portalService);
await portalService.login(
TestCredentials.username,
TestCredentials.password,
);
});
test('should return calendar events for a semester date range', () async {
final events = await calendarService.getCalendar(
DateTime(2025, 1, 1),
DateTime(2025, 6, 30),
);
expect(events, isNotEmpty, reason: 'Semester should have events');
// Verify structure of first event (skip holidays with empty titles)
final event = events.firstWhere((e) => e.calTitle != null);
expect(event.calTitle, isNotNull, reason: 'Event should have a title');
expect(
event.calStart,
isNotNull,
reason: 'Event should have a start time',
);
});
test('should return empty list for a date range with no events', () async {
// A single day far in the past unlikely to have events
final events = await calendarService.getCalendar(
DateTime(2000, 1, 1),
DateTime(2000, 1, 2),
);
// May still contain weekend/holiday markers, but should be a valid list
expect(events, isA<List>());
});
});
}