Test Cases
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -28,6 +30,29 @@ class _FakeProfileController implements ProfileController {
|
||||
Future<void> updatePassword(String password) async {
|
||||
lastPassword = password;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> uploadAvatar({
|
||||
required String userId,
|
||||
required Uint8List bytes,
|
||||
required String fileName,
|
||||
}) async {
|
||||
return 'https://example.com/avatar.jpg';
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> uploadFacePhoto({
|
||||
required String userId,
|
||||
required Uint8List bytes,
|
||||
required String fileName,
|
||||
}) async {
|
||||
return 'https://example.com/face.jpg';
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Uint8List?> downloadFacePhoto(String userId) async {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class _FakeUserOfficesController implements UserOfficesController {
|
||||
@@ -118,15 +143,15 @@ void main() {
|
||||
find.widgetWithText(TextFormField, 'Full name'),
|
||||
'New Name',
|
||||
);
|
||||
await tester.ensureVisible(find.text('Save details'));
|
||||
await tester.tap(find.text('Save details'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(fake.lastFullName, equals('New Name'));
|
||||
|
||||
// should show a success snackbar using the awesome_snackbar_content package
|
||||
// (AwesomeSnackbarContent uses its own SVG icons, not Material Icons)
|
||||
expect(find.byType(AwesomeSnackbarContent), findsOneWidget);
|
||||
// our helper adds a leading icon for even short messages
|
||||
expect(find.byIcon(Icons.check_circle), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('save offices assigns selected office', (tester) async {
|
||||
@@ -198,6 +223,7 @@ void main() {
|
||||
find.widgetWithText(TextFormField, 'Confirm password'),
|
||||
'new-pass-123',
|
||||
);
|
||||
await tester.ensureVisible(find.text('Change password'));
|
||||
await tester.tap(find.text('Change password'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user