From 578132d9eaf0f1df8547937f3c5bc25a103e0926 Mon Sep 17 00:00:00 2001 From: Greg Littlefield Date: Mon, 13 Feb 2023 16:17:47 -0700 Subject: [PATCH] Remove unnecessary List mock causing mockito builder issues Errors look like: Invalid @GenerateMocks annotation: Mockito cannot generate a valid mock class which implements 'List' for the following reasons: The method 'Iterable.reduce' features a non-nullable unknown return type, and cannot be stubbed. Try generating this mock with a MockSpec with 'unsupportedMembers' or a dummy generator (see https://pub.dev/documentation/mockito/latest/annotations/MockSpec-class.html). --- test/mockito.dart | 9 --------- test/mockito.mocks.dart | 11 +++++------ .../over_react_redux/value_mutation_checker_test.dart | 4 ---- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/test/mockito.dart b/test/mockito.dart index 0c14453b5..98d6f1cab 100644 --- a/test/mockito.dart +++ b/test/mockito.dart @@ -3,11 +3,6 @@ import 'package:mockito/annotations.dart'; @GenerateMocks([], customMocks: [ MockSpec(returnNullOnMissingStub: true), - MockSpec(fallbackGenerators: { - #[]: listIndexOperatorShim, - #removeAt: listRemoveAtShim, - #removeLast: listRemoveLastShim, - }, returnNullOnMissingStub: true), MockSpec(fallbackGenerators: { #update: mapUpdateShim, #putIfAbsent: mapPutIfAbsentShim, @@ -15,10 +10,6 @@ import 'package:mockito/annotations.dart'; ]) void main() {} -dynamic listIndexOperatorShim(int index) => 1; -dynamic listRemoveAtShim(int index) => 1; -dynamic listRemoveLastShim() => 1; - String mapUpdateShim(K key, V Function(V value) update, {V Function() ifAbsent}) => 'value'; diff --git a/test/mockito.mocks.dart b/test/mockito.mocks.dart index 054b2ee46..106539dc6 100644 --- a/test/mockito.mocks.dart +++ b/test/mockito.mocks.dart @@ -1,11 +1,14 @@ -// Mocks generated by Mockito 5.0.15 from annotations +// Mocks generated by Mockito 5.2.0 from annotations // in over_react/test/mockito.dart. // Do not manually edit this file. +// @dart=2.9 + // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:logging/src/logger.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; +// ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references @@ -13,17 +16,13 @@ import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types /// A class which mocks [Logger]. /// /// See the documentation for Mockito's code generation for more information. class MockLogger extends _i1.Mock implements _i2.Logger {} -/// A class which mocks [List]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockList extends _i1.Mock implements List {} - /// A class which mocks [Map]. /// /// See the documentation for Mockito's code generation for more information. diff --git a/test/over_react_redux/value_mutation_checker_test.dart b/test/over_react_redux/value_mutation_checker_test.dart index 7dd9ce263..935268855 100644 --- a/test/over_react_redux/value_mutation_checker_test.dart +++ b/test/over_react_redux/value_mutation_checker_test.dart @@ -17,8 +17,6 @@ import 'package:over_react/src/over_react_redux/value_mutation_checker.dart'; import 'package:react/react.dart' as react; import 'package:test/test.dart'; -import '../mockito.mocks.dart'; - // ignore_for_file: invalid_use_of_protected_member main() { group('Value Mutation Checker:', () { @@ -106,13 +104,11 @@ void sharedHashTests(InstanceHasher Function() getHasher) { test('true if the object is a map or iterable', () { final props = DomProps(react.a as ReactComponentFactoryProxy); - final list = MockList(); expect(hasher.canHash({'e', 'a', 'b'}), isTrue); expect(hasher.canHash([]), isTrue); expect(hasher.canHash({'a': 1}), isTrue); expect(hasher.canHash(props), isTrue); - expect(hasher.canHash(list), isTrue); }); });