Skip to content

Commit 6953523

Browse files
Add one more test case
1 parent d5b3150 commit 6953523

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/src/dart3_suggestors/null_safety_prep/connect_required_props.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class ConnectRequiredProps extends RecursiveAstVisitor with ClassSuggestor {
5858
// Keep a running list of props to ignore per props mixin.
5959
final fieldName = field.name.name;
6060
if (_ignoredPropsByMixin[propsElement] != null) {
61-
_ignoredPropsByMixin[propsElement]!.add(fieldName);
61+
if (!_ignoredPropsByMixin[propsElement]!.contains(fieldName)) {
62+
_ignoredPropsByMixin[propsElement]!.add(fieldName);
63+
}
6264
} else {
6365
_ignoredPropsByMixin[propsElement] = [fieldName];
6466
}

test/dart3_suggestors/null_safety_prep/connect_required_props_test.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,25 @@ void main() {
5656
final input = '''
5757
mixin FooProps on UiProps {
5858
num setInMapStateToProps;
59-
Function() SetInMapDispatchToProps;
59+
Function() setInMapDispatchToProps;
60+
num setInBoth;
6061
String notSetInConnect;
6162
}
6263
6364
UiFactory<FooProps> Foo = connect<FooState, FooProps>(
6465
mapStateToProps: (state) => (Foo()
6566
..addTestId('abc')
6667
..setInMapStateToProps = state.count
68+
..setInBoth = 1
6769
),
68-
mapDispatchToProps: (dispatch) => Foo()..SetInMapDispatchToProps = (() => null),
70+
mapDispatchToProps: (dispatch) => Foo()..setInMapDispatchToProps = (() => null)..setInBoth = 1,
6971
)(uiFunction((props) => (Foo()..notSetInConnect = '1')(), _\$Foo));
7072
''';
7173

7274
await testSuggestor(
7375
input: commonConnectFile(input),
7476
expectedOutput: commonConnectFile('''
75-
@Props(disableRequiredPropValidation: {'setInMapStateToProps', 'SetInMapDispatchToProps'})
77+
@Props(disableRequiredPropValidation: {'setInMapStateToProps', 'setInBoth', 'setInMapDispatchToProps'})
7678
$input
7779
'''),
7880
);

0 commit comments

Comments
 (0)