ok for now
This commit is contained in:
+41
-8
@@ -1,9 +1,11 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:myapp/main.dart';
|
||||
import 'package:myapp/models/bank.dart';
|
||||
import 'package:myapp/models/transaction_meta.dart';
|
||||
import 'package:myapp/services/storage_service.dart';
|
||||
import 'package:myapp/utils/constants.dart';
|
||||
import 'package:myapp/utils/helpers.dart';
|
||||
import 'package:myapp/utils/look_ahead.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
void main() {
|
||||
@@ -16,7 +18,7 @@ void main() {
|
||||
await tester.pumpWidget(MyApp(storage: storage));
|
||||
}
|
||||
|
||||
testWidgets('splash shows the app name then opens Balance', (tester) async {
|
||||
testWidgets('splash shows the app name then opens Home', (tester) async {
|
||||
await pumpApp(tester);
|
||||
|
||||
expect(find.text(kAppName), findsWidgets);
|
||||
@@ -25,9 +27,9 @@ void main() {
|
||||
await tester.pump(const Duration(milliseconds: 450));
|
||||
await tester.pump(const Duration(milliseconds: 350));
|
||||
|
||||
expect(find.text('Balance'), findsWidgets);
|
||||
expect(find.text('Transactions'), findsOneWidget);
|
||||
expect(find.text('Settings'), findsOneWidget);
|
||||
expect(find.text('Home'), findsWidgets);
|
||||
expect(find.text('Overview'), findsOneWidget);
|
||||
expect(find.byTooltip('Settings'), findsOneWidget);
|
||||
});
|
||||
|
||||
test('ConnectStart.fromJson maps authUrl and state', () {
|
||||
@@ -39,16 +41,47 @@ void main() {
|
||||
expect(start.state, 'abc');
|
||||
});
|
||||
|
||||
test('BankTransaction.fromJson maps API fields', () {
|
||||
test('BankTransaction match keys support auto-category and notes', () {
|
||||
final tx = BankTransaction.fromJson({
|
||||
'date': '2026-09-01',
|
||||
'description': 'Coffee',
|
||||
'description': 'Coffee Shop',
|
||||
'amount': -3.5,
|
||||
'currency': 'EUR',
|
||||
'pending': false,
|
||||
});
|
||||
expect(tx.description, 'Coffee');
|
||||
expect(tx.amount, -3.5);
|
||||
expect(tx.descriptionKey, 'coffee shop');
|
||||
expect(tx.exactKey, contains('coffee shop'));
|
||||
expect(tx.exactKey, contains('-3.5'));
|
||||
expect(formatMoney(tx.amount, tx.currency), contains('EUR'));
|
||||
expect(TxCategory.groceries.label, 'Groceries');
|
||||
});
|
||||
|
||||
test('look-ahead applies monthly recurring amounts', () {
|
||||
final items = [
|
||||
const RecurringItem(
|
||||
description: 'Salary',
|
||||
amount: 2000,
|
||||
currency: 'EUR',
|
||||
dayOfMonth: 25,
|
||||
category: TxCategory.salary,
|
||||
),
|
||||
const RecurringItem(
|
||||
description: 'Rent',
|
||||
amount: -900,
|
||||
currency: 'EUR',
|
||||
dayOfMonth: 1,
|
||||
category: TxCategory.mortgage,
|
||||
),
|
||||
];
|
||||
final from = DateTime(2026, 9, 6);
|
||||
final through = DateTime(2026, 10, 31);
|
||||
final predicted = predictBalance(
|
||||
currentBalance: 1000,
|
||||
from: from,
|
||||
throughDate: through,
|
||||
items: items,
|
||||
);
|
||||
// Sep 25 salary + Oct 1 rent + Oct 25 salary = 1000+2000-900+2000
|
||||
expect(predicted, 4100);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user