Skip to content

Commit 8e6eadf

Browse files
committed
Annotate the needed mocks for each test
This makes it clear where they are loaded from
1 parent fcfa1ce commit 8e6eadf

File tree

5 files changed

+549
-7
lines changed

5 files changed

+549
-7
lines changed

test/gallery/gallery_form_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@
1919
import 'package:flutter/material.dart';
2020
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
2121
import 'package:flutter_test/flutter_test.dart';
22+
import 'package:mockito/annotations.dart';
2223
import 'package:mockito/mockito.dart';
2324
import 'package:network_image_mock/network_image_mock.dart';
2425
import 'package:provider/provider.dart';
2526
import 'package:wger/helpers/consts.dart';
2627
import 'package:wger/models/gallery/image.dart' as gallery;
2728
import 'package:wger/providers/gallery.dart';
2829
import 'package:wger/widgets/gallery/forms.dart';
29-
30-
import './gallery_screen_test.mocks.dart';
3130
import '../../test_data/gallery.dart';
31+
import 'gallery_form_test.mocks.dart';
3232

33+
@GenerateMocks([GalleryProvider])
3334
void main() {
3435
late gallery.Image image;
3536
final mockGalleryProvider = MockGalleryProvider();
Lines changed: 324 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,324 @@
1+
// Mocks generated by Mockito 5.3.2 from annotations
2+
// in wger/test/gallery/gallery_form_test.dart.
3+
// Do not manually edit this file.
4+
5+
// ignore_for_file: no_leading_underscores_for_library_prefixes
6+
import 'dart:async' as _i6;
7+
import 'dart:ui' as _i8;
8+
9+
import 'package:http/http.dart' as _i3;
10+
import 'package:image_picker/image_picker.dart' as _i7;
11+
import 'package:mockito/mockito.dart' as _i1;
12+
import 'package:wger/models/gallery/image.dart' as _i5;
13+
import 'package:wger/providers/auth.dart' as _i2;
14+
import 'package:wger/providers/gallery.dart' as _i4;
15+
16+
// ignore_for_file: type=lint
17+
// ignore_for_file: avoid_redundant_argument_values
18+
// ignore_for_file: avoid_setters_without_getters
19+
// ignore_for_file: comment_references
20+
// ignore_for_file: implementation_imports
21+
// ignore_for_file: invalid_use_of_visible_for_testing_member
22+
// ignore_for_file: prefer_const_constructors
23+
// ignore_for_file: unnecessary_parenthesis
24+
// ignore_for_file: camel_case_types
25+
// ignore_for_file: subtype_of_sealed_class
26+
27+
class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider {
28+
_FakeAuthProvider_0(
29+
Object parent,
30+
Invocation parentInvocation,
31+
) : super(
32+
parent,
33+
parentInvocation,
34+
);
35+
}
36+
37+
class _FakeClient_1 extends _i1.SmartFake implements _i3.Client {
38+
_FakeClient_1(
39+
Object parent,
40+
Invocation parentInvocation,
41+
) : super(
42+
parent,
43+
parentInvocation,
44+
);
45+
}
46+
47+
class _FakeUri_2 extends _i1.SmartFake implements Uri {
48+
_FakeUri_2(
49+
Object parent,
50+
Invocation parentInvocation,
51+
) : super(
52+
parent,
53+
parentInvocation,
54+
);
55+
}
56+
57+
class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response {
58+
_FakeResponse_3(
59+
Object parent,
60+
Invocation parentInvocation,
61+
) : super(
62+
parent,
63+
parentInvocation,
64+
);
65+
}
66+
67+
/// A class which mocks [GalleryProvider].
68+
///
69+
/// See the documentation for Mockito's code generation for more information.
70+
class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
71+
MockGalleryProvider() {
72+
_i1.throwOnMissingStub(this);
73+
}
74+
75+
@override
76+
List<_i5.Image> get images => (super.noSuchMethod(
77+
Invocation.getter(#images),
78+
returnValue: <_i5.Image>[],
79+
) as List<_i5.Image>);
80+
@override
81+
set images(List<_i5.Image>? _images) => super.noSuchMethod(
82+
Invocation.setter(
83+
#images,
84+
_images,
85+
),
86+
returnValueForMissingStub: null,
87+
);
88+
@override
89+
_i2.AuthProvider get auth => (super.noSuchMethod(
90+
Invocation.getter(#auth),
91+
returnValue: _FakeAuthProvider_0(
92+
this,
93+
Invocation.getter(#auth),
94+
),
95+
) as _i2.AuthProvider);
96+
@override
97+
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
98+
Invocation.setter(
99+
#auth,
100+
_auth,
101+
),
102+
returnValueForMissingStub: null,
103+
);
104+
@override
105+
_i3.Client get client => (super.noSuchMethod(
106+
Invocation.getter(#client),
107+
returnValue: _FakeClient_1(
108+
this,
109+
Invocation.getter(#client),
110+
),
111+
) as _i3.Client);
112+
@override
113+
set client(_i3.Client? _client) => super.noSuchMethod(
114+
Invocation.setter(
115+
#client,
116+
_client,
117+
),
118+
returnValueForMissingStub: null,
119+
);
120+
@override
121+
bool get hasListeners => (super.noSuchMethod(
122+
Invocation.getter(#hasListeners),
123+
returnValue: false,
124+
) as bool);
125+
@override
126+
void clear() => super.noSuchMethod(
127+
Invocation.method(
128+
#clear,
129+
[],
130+
),
131+
returnValueForMissingStub: null,
132+
);
133+
@override
134+
_i6.Future<void> fetchAndSetGallery() => (super.noSuchMethod(
135+
Invocation.method(
136+
#fetchAndSetGallery,
137+
[],
138+
),
139+
returnValue: _i6.Future<void>.value(),
140+
returnValueForMissingStub: _i6.Future<void>.value(),
141+
) as _i6.Future<void>);
142+
@override
143+
_i6.Future<void> addImage(
144+
_i5.Image? image,
145+
_i7.XFile? imageFile,
146+
) =>
147+
(super.noSuchMethod(
148+
Invocation.method(
149+
#addImage,
150+
[
151+
image,
152+
imageFile,
153+
],
154+
),
155+
returnValue: _i6.Future<void>.value(),
156+
returnValueForMissingStub: _i6.Future<void>.value(),
157+
) as _i6.Future<void>);
158+
@override
159+
_i6.Future<void> editImage(
160+
_i5.Image? image,
161+
_i7.XFile? imageFile,
162+
) =>
163+
(super.noSuchMethod(
164+
Invocation.method(
165+
#editImage,
166+
[
167+
image,
168+
imageFile,
169+
],
170+
),
171+
returnValue: _i6.Future<void>.value(),
172+
returnValueForMissingStub: _i6.Future<void>.value(),
173+
) as _i6.Future<void>);
174+
@override
175+
_i6.Future<void> deleteImage(_i5.Image? image) => (super.noSuchMethod(
176+
Invocation.method(
177+
#deleteImage,
178+
[image],
179+
),
180+
returnValue: _i6.Future<void>.value(),
181+
returnValueForMissingStub: _i6.Future<void>.value(),
182+
) as _i6.Future<void>);
183+
@override
184+
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) => (super.noSuchMethod(
185+
Invocation.method(
186+
#getDefaultHeaders,
187+
[],
188+
{#includeAuth: includeAuth},
189+
),
190+
returnValue: <String, String>{},
191+
) as Map<String, String>);
192+
@override
193+
Uri makeUrl(
194+
String? path, {
195+
int? id,
196+
String? objectMethod,
197+
Map<String, dynamic>? query,
198+
}) =>
199+
(super.noSuchMethod(
200+
Invocation.method(
201+
#makeUrl,
202+
[path],
203+
{
204+
#id: id,
205+
#objectMethod: objectMethod,
206+
#query: query,
207+
},
208+
),
209+
returnValue: _FakeUri_2(
210+
this,
211+
Invocation.method(
212+
#makeUrl,
213+
[path],
214+
{
215+
#id: id,
216+
#objectMethod: objectMethod,
217+
#query: query,
218+
},
219+
),
220+
),
221+
) as Uri);
222+
@override
223+
_i6.Future<Map<String, dynamic>> fetch(Uri? uri) => (super.noSuchMethod(
224+
Invocation.method(
225+
#fetch,
226+
[uri],
227+
),
228+
returnValue: _i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
229+
) as _i6.Future<Map<String, dynamic>>);
230+
@override
231+
_i6.Future<List<dynamic>> fetchPaginated(Uri? uri) => (super.noSuchMethod(
232+
Invocation.method(
233+
#fetchPaginated,
234+
[uri],
235+
),
236+
returnValue: _i6.Future<List<dynamic>>.value(<dynamic>[]),
237+
) as _i6.Future<List<dynamic>>);
238+
@override
239+
_i6.Future<Map<String, dynamic>> post(
240+
Map<String, dynamic>? data,
241+
Uri? uri,
242+
) =>
243+
(super.noSuchMethod(
244+
Invocation.method(
245+
#post,
246+
[
247+
data,
248+
uri,
249+
],
250+
),
251+
returnValue: _i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
252+
) as _i6.Future<Map<String, dynamic>>);
253+
@override
254+
_i6.Future<Map<String, dynamic>> patch(
255+
Map<String, dynamic>? data,
256+
Uri? uri,
257+
) =>
258+
(super.noSuchMethod(
259+
Invocation.method(
260+
#patch,
261+
[
262+
data,
263+
uri,
264+
],
265+
),
266+
returnValue: _i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
267+
) as _i6.Future<Map<String, dynamic>>);
268+
@override
269+
_i6.Future<_i3.Response> deleteRequest(
270+
String? url,
271+
int? id,
272+
) =>
273+
(super.noSuchMethod(
274+
Invocation.method(
275+
#deleteRequest,
276+
[
277+
url,
278+
id,
279+
],
280+
),
281+
returnValue: _i6.Future<_i3.Response>.value(_FakeResponse_3(
282+
this,
283+
Invocation.method(
284+
#deleteRequest,
285+
[
286+
url,
287+
id,
288+
],
289+
),
290+
)),
291+
) as _i6.Future<_i3.Response>);
292+
@override
293+
void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(
294+
Invocation.method(
295+
#addListener,
296+
[listener],
297+
),
298+
returnValueForMissingStub: null,
299+
);
300+
@override
301+
void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod(
302+
Invocation.method(
303+
#removeListener,
304+
[listener],
305+
),
306+
returnValueForMissingStub: null,
307+
);
308+
@override
309+
void dispose() => super.noSuchMethod(
310+
Invocation.method(
311+
#dispose,
312+
[],
313+
),
314+
returnValueForMissingStub: null,
315+
);
316+
@override
317+
void notifyListeners() => super.noSuchMethod(
318+
Invocation.method(
319+
#notifyListeners,
320+
[],
321+
),
322+
returnValueForMissingStub: null,
323+
);
324+
}

test/gallery/gallery_provider_test.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
import 'package:flutter_test/flutter_test.dart';
2020
import 'package:http/http.dart' as http;
2121
import 'package:mockito/mockito.dart';
22+
import 'package:wger/models/gallery/image.dart' as gallery;
2223
import 'package:wger/providers/gallery.dart';
24+
2325
import '../other/base_provider_test.mocks.dart';
24-
import 'package:wger/models/gallery/image.dart' as gallery;
2526
import '../utils.dart';
2627

2728
void main() {
@@ -41,7 +42,7 @@ void main() {
4142
'"height":1280,"width":960}]}',
4243
200));
4344

44-
GalleryProvider galleryProvider = GalleryProvider(testAuthProvider, [], client);
45+
final galleryProvider = GalleryProvider(testAuthProvider, [], client);
4546

4647
await galleryProvider.fetchAndSetGallery();
4748

@@ -63,9 +64,9 @@ void main() {
6364
'"height":1280,"width":960}',
6465
200));
6566

66-
GalleryProvider galleryProvider = GalleryProvider(testAuthProvider, [], client);
67+
final galleryProvider = GalleryProvider(testAuthProvider, [], client);
6768

68-
gallery.Image image = gallery.Image(
69+
final image = gallery.Image(
6970
id: 58,
7071
date: DateTime(2022, 01, 09),
7172
url: "https://wger.de/media/gallery/170335/d2b9c9e0-d541-41ae-8786-a2ab459e3538.jpg",

test/user/provider_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
import 'dart:convert';
2020

2121
import 'package:flutter_test/flutter_test.dart';
22+
import 'package:mockito/annotations.dart';
2223
import 'package:mockito/mockito.dart';
24+
import 'package:wger/providers/base_provider.dart';
2325
import 'package:wger/providers/user.dart';
2426

2527
import '../fixtures/fixture_reader.dart';
26-
import '../measurements/measurement_provider_test.mocks.dart';
28+
import 'provider_test.mocks.dart';
2729

30+
@GenerateMocks([WgerBaseProvider])
2831
void main() {
2932
late UserProvider userProvider;
3033
late MockWgerBaseProvider mockWgerBaseProvider;

0 commit comments

Comments
 (0)