Skip to content

Commit

Permalink
Test improvements: avoid false positives, clean up connectOptions, fi…
Browse files Browse the repository at this point in the history
…x unused local vars
  • Loading branch information
greglittlefield-wf committed Nov 20, 2023
1 parent c3e6ee4 commit 9c2b4de
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions test/over_react_redux/connect_flux_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ main() {
bigFluxActions = FluxActions();
bigFluxCounter = FluxStore2(bigFluxActions);
store2 = FluxToReduxAdapterStore(bigFluxCounter, bigFluxActions);
connectOptions = null;
});

group('behaves like redux with', () {
Expand Down Expand Up @@ -217,6 +218,7 @@ main() {

final ConnectedCounter = connectFlux<FluxStore, FluxActions, ConnectFluxCounterProps>(
mapStateToProps: (state) {
stateReferences.add(state);
return ConnectFluxCounter()..currentCount = state.count;
},
mapActionsToProps: (actions) => (ConnectFluxCounter()
Expand Down Expand Up @@ -245,7 +247,7 @@ main() {

expect(counterRef.current!.props.currentCount, -1);
expect(jacket.mountNode.innerHtml, contains('Count: -1'));
stateReferences.forEach((store) => expect(store, isA<FluxStore>()));
expect(stateReferences, allOf(isNotEmpty, everyElement(isA<FluxStore>())));
});
});

Expand Down Expand Up @@ -283,7 +285,7 @@ main() {

expect(counterRef.current!.props.currentCount, -1);
expect(jacket.mountNode.innerHtml, contains('Count: -1'));
stateReferences.forEach((store) => expect(store, isA<FluxStore>()));
expect(stateReferences, allOf(isNotEmpty, everyElement(isA<FluxStore>())));
});
});

Expand Down Expand Up @@ -334,15 +336,16 @@ main() {

expect(counterRef.current!.props.currentCount, 1);
expect(jacket.mountNode.innerHtml, contains('Count: 1'));
propsReferences.forEach((store) => expect(store, isA<ConnectFluxCounterProps>()));
expect(propsReferences, allOf(isNotEmpty, everyElement(isA<ConnectFluxCounterProps>())));
});
});

group('Options', () {
group('areOwnPropsEqual', () {
test('', () {
final propsReferences = <ConnectFluxCounterProps>[];
final ConnectedCounter = connectFlux<FluxStore, FluxActions, ConnectFluxCounterProps>(
// This component isn't used; we're just calling this to get `connectOptions`.
connectFlux<FluxStore, FluxActions, ConnectFluxCounterProps>(
areOwnPropsEqual: expectAsync2((next, prev) {
propsReferences.addAll([prev, next]);
expect(next.id, 'test');
Expand All @@ -356,7 +359,7 @@ main() {
JsBackedMap.from({'id': 'test2'}).jsObject);

expect(whatever, isTrue);
propsReferences.forEach((store) => expect(store, isA<ConnectFluxCounterProps>()));
expect(propsReferences, allOf(isNotEmpty, everyElement(isA<ConnectFluxCounterProps>())));
});
});

Expand Down Expand Up @@ -524,10 +527,13 @@ main() {
test('', () {
final propsReferences = <ConnectFluxCounterProps>[];

final ConnectedCounter = connectFlux<FluxStore, FluxActions, ConnectFluxCounterProps>(
// This component isn't used; we're just calling this to get `connectOptions`.
connectFlux<FluxStore, FluxActions, ConnectFluxCounterProps>(
areMergedPropsEqual: expectAsync2((next, prev) {
expect(next.id, 'test');
expect(prev.id, 'test2');
propsReferences.add(next);
propsReferences.add(prev);
return true;
}),
pure: false,
Expand All @@ -538,7 +544,7 @@ main() {
JsBackedMap.from({'id': 'test2'}).jsObject);

expect(whatever, isTrue);
propsReferences.forEach((store) => expect(store, isA<ConnectFluxCounterProps>()));
expect(propsReferences, allOf(isNotEmpty, everyElement(isA<ConnectFluxCounterProps>())));
});
});
});
Expand Down

0 comments on commit 9c2b4de

Please sign in to comment.