Доходы, ребалансировка, налоги, импорт, цели, здоровье данных, правила, транзакции, категории, cashflow, pending: новые виджеты и токены темы, dart format. Тесты подстроены под новые модели.
43 lines
1.3 KiB
Dart
43 lines
1.3 KiB
Dart
import 'package:dio/dio.dart';
|
|
import 'package:fintracker_app/core/api/api_client.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
/// Captures whatever `onRequest` passes on, so the rewritten query can be inspected.
|
|
class _Capture extends RequestInterceptorHandler {
|
|
RequestOptions? seen;
|
|
|
|
@override
|
|
void next(RequestOptions options) => seen = options;
|
|
}
|
|
|
|
void main() {
|
|
RequestOptions run(Map<String, dynamic> query) {
|
|
final handler = _Capture();
|
|
DateQueryInterceptor().onRequest(
|
|
RequestOptions(path: '/networth/series', queryParameters: query),
|
|
handler,
|
|
);
|
|
return handler.seen!;
|
|
}
|
|
|
|
test('a DateTime becomes a plain YYYY-MM-DD date', () {
|
|
// the value the generated client hands over: DateTime.now(), time and all
|
|
final out = run({'from': DateTime(2025, 9, 18, 10, 31, 29, 84)});
|
|
expect(out.queryParameters['from'], '2025-09-18');
|
|
});
|
|
|
|
test('single-digit months and days keep two digits', () {
|
|
final out = run({'from': DateTime(2026, 1, 5)});
|
|
expect(out.queryParameters['from'], '2026-01-05');
|
|
});
|
|
|
|
test('non-date parameters are passed through untouched', () {
|
|
final out = run({'page': 2, 'q': 'кофе', 'include_deleted': false});
|
|
expect(out.queryParameters, {
|
|
'page': 2,
|
|
'q': 'кофе',
|
|
'include_deleted': false,
|
|
});
|
|
});
|
|
}
|