-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy patherror_text_test.dart
More file actions
63 lines (55 loc) · 1.74 KB
/
error_text_test.dart
File metadata and controls
63 lines (55 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2023, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:firebase_auth/firebase_auth.dart' as fba;
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
import 'package:firebase_ui_localizations/firebase_ui_localizations.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
final exception = fba.FirebaseAuthException(
code: 'invalid-email',
message: 'The email address is badly formatted.',
);
group('$ErrorText', () {
tearDown(() {
ErrorText.localizeError = null;
});
testWidgets('uses localizations', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: ErrorText(exception: exception),
localizationsDelegates: const [
FirebaseUILocalizations.delegate,
],
),
);
expect(
find.text('The email address is badly formatted.'),
findsOneWidget,
);
});
testWidgets('allows to override error text', (tester) async {
String localizeError(
BuildContext context,
fba.FirebaseAuthException exception,
) {
expect(exception.code, 'invalid-email');
return 'Custom error text';
}
ErrorText.localizeError = localizeError;
await tester.pumpWidget(
MaterialApp(
home: ErrorText(exception: exception),
localizationsDelegates: const [
FirebaseUILocalizations.delegate,
],
),
);
expect(
find.text('Custom error text'),
findsOneWidget,
);
});
});
}