Files
Client/test/widget/a11y_labels_test.dart
T

64 lines
1.9 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter_test/flutter_test.dart';
import 'package:jiffy/jiffy.dart';
import 'package:marianum_mobile/widget/a11y/a11y_labels.dart';
void main() {
setUpAll(() async {
// appointmentLabel formatiert über formatHm() (Jiffy) Locale einmal laden.
await Jiffy.setLocale('de');
});
group('A11yLabels.appointmentLabel', () {
test('setzt Fach, Ort und Zeitspanne zusammen', () {
final label = A11yLabels.appointmentLabel(
subject: 'Mathe',
location: 'Raum 101',
start: DateTime(2026, 5, 8, 8, 0),
end: DateTime(2026, 5, 8, 8, 45),
crossedOut: false,
);
expect(label, 'Mathe, Raum 101, 08:0008:45');
});
test('hängt bei Ausfall den Ausfall-Hinweis an', () {
final label = A11yLabels.appointmentLabel(
subject: 'Deutsch',
location: 'Raum 5',
start: DateTime(2026, 5, 8, 9, 0),
end: DateTime(2026, 5, 8, 9, 45),
crossedOut: true,
);
expect(label, endsWith(A11yLabels.cancelled));
expect(label, 'Deutsch, Raum 5, 09:0009:45, Ausfall');
});
test('glättet Zeilenumbrüche im Ort zu Trennern', () {
final label = A11yLabels.appointmentLabel(
subject: 'Sport',
location: 'Halle\nHr. Müller',
start: DateTime(2026, 5, 8, 10, 0),
end: DateTime(2026, 5, 8, 10, 45),
crossedOut: false,
);
expect(label, 'Sport, Halle, Hr. Müller, 10:0010:45');
});
test('lässt einen leeren Ort weg', () {
final label = A11yLabels.appointmentLabel(
subject: 'Pause',
location: '',
start: DateTime(2026, 5, 8, 11, 0),
end: DateTime(2026, 5, 8, 11, 15),
crossedOut: false,
);
expect(label, 'Pause, 11:0011:15');
});
});
group('A11yLabels.moreAppointments', () {
test('pluralisiert die Overflow-Beschriftung', () {
expect(A11yLabels.moreAppointments(3), '+3 weitere Termine');
});
});
}