Files
ignis_app/test/schedule_form_logic_test.dart
2026-05-01 09:47:08 +07:00

44 lines
1.6 KiB
Dart
Raw Permalink 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:ignis_app/features/schedules/schedule_form_logic.dart';
void main() {
test('default once time rounds forward and stays in future', () {
final now = DateTime(2026, 5, 1, 10, 2);
final result = defaultOnceScheduleTime(now: now);
expect(result, DateTime(2026, 5, 1, 14, 5));
expect(result.isAfter(now), isTrue);
});
test('once validation rejects missing and past dates', () {
final now = DateTime(2026, 5, 1, 10, 0);
expect(validateOnceSchedule(null, now: now), 'Выберите дату и время');
expect(
validateOnceSchedule(now.add(const Duration(seconds: 30)), now: now),
'Нужна дата хотя бы на минуту вперёд',
);
expect(
validateOnceSchedule(now.add(const Duration(minutes: 2)), now: now),
isNull,
);
});
test('cron weekday serialization and descriptions stay human readable', () {
expect(serializeCronWeekdays({0, 1, 2, 3, 4, 5, 6}), '*');
expect(serializeCronWeekdays({1, 5, 0}), '0,1,5');
expect(describeCronWeekdays({1, 2, 3, 4, 5}), 'Пн, Вт, Ср, Чт, Пт');
expect(describeCronWeekdaysExpression('*'), 'каждый день');
expect(describeCronWeekdaysExpression('1,5,0'), 'Пн, Пт, Вс');
});
test('format runAt converts utc timestamp to local label', () {
final label = formatRunAtLabel('2026-05-01T12:30:00Z');
expect(label, isNotEmpty);
expect(label.contains('2026'), isTrue);
expect(label.contains('12:30') || label.contains('19:30'), isTrue);
});
}