import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:kalkulator/main.dart'; void main() { testWidgets('displays 0 on start', (tester) async { await tester.pumpWidget(const KalkulatorApp()); // '0' appears on both the display and the '0' button expect(find.text('0'), findsWidgets); }); testWidgets('tapping digit updates display', (tester) async { await tester.pumpWidget(const KalkulatorApp()); await tester.tap(find.text('5')); await tester.pump(); expect(find.text('5'), findsWidgets); }); testWidgets('simple addition 3 + 2 = 5', (tester) async { await tester.pumpWidget(const KalkulatorApp()); await tester.tap(find.text('3')); await tester.pump(); await tester.tap(find.text('+')); await tester.pump(); await tester.tap(find.text('2')); await tester.pump(); await tester.tap(find.text('=')); await tester.pump(); expect(find.text('5'), findsWidgets); }); testWidgets('clear resets display to 0', (tester) async { await tester.pumpWidget(const KalkulatorApp()); await tester.tap(find.text('7')); await tester.pump(); await tester.tap(find.text('C')); await tester.pump(); expect(find.text('0'), findsWidgets); }); testWidgets('all buttons are rendered', (tester) async { await tester.pumpWidget(const KalkulatorApp()); for (final label in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']) { expect(find.text(label), findsWidgets); } for (final label in ['+', '-', '*', '/', '=', 'C', '.', '%', '+/-']) { expect(find.text(label), findsOneWidget); } }); }