Files
please-pay-me/mobile/test/formatters_test.dart
T
2026-09-21 04:06:43 +03:00

39 lines
1.3 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:please_pay_me/core/format/formatters.dart';
import 'support/test_setup.dart';
void main() {
setUpAll(setUpTestEnvironment);
test('money uses Russian grouping and the ruble sign', () {
expect(formatMoney(1234.5), '1 234,50 ₽');
expect(formatMoney(250, compact: true), '250 ₽');
});
test('expenses are rendered as a deduction', () {
expect(formatSignedMoney(250), '250,00 ₽');
expect(formatSignedMoney(-250), '+250,00 ₽');
});
test('plural follows Russian rules', () {
expect(plural(1, 'день', 'дня', 'дней'), '1 день');
expect(plural(3, 'день', 'дня', 'дней'), '3 дня');
expect(plural(11, 'день', 'дня', 'дней'), '11 дней');
expect(plural(21, 'день', 'дня', 'дней'), '21 день');
});
test('relative day switches to a date beyond yesterday', () {
final now = DateTime(2026, 9, 19);
expect(formatRelativeDay(now, now: now), 'Сегодня');
expect(formatRelativeDay(DateTime(2026, 9, 18), now: now), 'Вчера');
expect(formatRelativeDay(DateTime(2026, 9, 12), now: now), '12 сентября');
});
test('days left is humanized', () {
expect(formatDaysLeft(0), 'период завершён');
expect(formatDaysLeft(5), 'осталось 5 дней');
});
}