Skip to content

Commit

Permalink
test: update password
Browse files Browse the repository at this point in the history
  • Loading branch information
thelukewalton committed Jun 24, 2024
1 parent 3a6be95 commit 3cd93fc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
8 changes: 1 addition & 7 deletions lib/src/components/password/password_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,8 @@ class ZetaPasswordInput extends ZetaFormField<String> {
..add(StringProperty('hintText', hintText))
..add(StringProperty('label', label))
..add(StringProperty('footerText', hintText))
..add(
ObjectFlagProperty<String? Function(String? p1)?>.has(
'validator',
validator,
),
)
..add(ObjectFlagProperty<String? Function(String? p1)?>.has('validator', validator))
..add(EnumProperty<ZetaWidgetSize>('size', size))
..add(DiagnosticsProperty<bool>('rounded', rounded))
..add(StringProperty('placeholder', placeholder))
..add(ObjectFlagProperty<void Function(String? val)?>.has('onSubmit', onSubmit))
..add(StringProperty('errorText', errorText));
Expand Down
21 changes: 21 additions & 0 deletions test/src/components/password/password_input_test.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../../test_utils/test_app.dart';
import '../../../test_utils/utils.dart';

void main() {
testWidgets('ZetaPasswordInput initializes correctly', (WidgetTester tester) async {
Expand Down Expand Up @@ -46,6 +48,7 @@ void main() {
child: ZetaPasswordInput(
controller: controller,
validator: testValidator,
rounded: false,
),
),
),
Expand All @@ -55,5 +58,23 @@ void main() {

// There will be two matches for the error text as the form field itself contains a hidden one.
expect(find.text('Error'), findsExactly(2));
final obscureIconOn = find.byIcon(ZetaIcons.visibility_off_sharp);
expect(obscureIconOn, findsOneWidget);
});

testWidgets('debugFillProperties works correctly', (WidgetTester tester) async {
final diagnostics = DiagnosticPropertiesBuilder();
const ZetaPasswordInput().debugFillProperties(diagnostics);

expect(diagnostics.finder('controller'), 'null');
expect(diagnostics.finder('obscureText'), 'true');
expect(diagnostics.finder('hintText'), 'null');
expect(diagnostics.finder('label'), 'null');
expect(diagnostics.finder('footerText'), 'null');
expect(diagnostics.finder('validator'), 'null');
expect(diagnostics.finder('size'), 'large');
expect(diagnostics.finder('placeholder'), 'null');
expect(diagnostics.finder('onSubmit'), 'null');
expect(diagnostics.finder('errorText'), 'null');
});
}

0 comments on commit 3cd93fc

Please sign in to comment.