ModernMemoires/test/set_pin_popup_widget_test.dart

33 lines
998 B
Dart
Raw Permalink Normal View History

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:moody/views/settings_page/widgets/set_pin_popup_widget.dart';
void main() {
testWidgets('SetPinPopup displays number pad and updates PIN', (WidgetTester tester) async {
// Create the widget by telling the tester to build it
await tester.pumpWidget(const MaterialApp(home: SetPinPopup()));
// Verify that the number pad is displayed
for (var i = 0; i <= 9; i++) {
expect(find.text('$i'), findsOneWidget);
}
// Tap on the number buttons and check if the PIN is updated
for (var i = 1; i <= 4; i++) {
await tester.tap(find.text('$i'));
await tester.pump();
}
// After entering 4 digits, check if the state changes to confirm PIN
expect(find.text('Repeat PIN'), findsOneWidget);
// Enter the confirmation PIN
for (var i = 1; i <= 4; i++) {
await tester.tap(find.text('$i'));
await tester.pump();
}
});
}