Skip to content

Commit faeabbe

Browse files
committed
✅ Tests refactoring
1 parent f0f3162 commit faeabbe

File tree

5 files changed

+131
-190
lines changed

5 files changed

+131
-190
lines changed

packages/core/test/assets_gen_integrations_test.dart

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,12 @@ void main() {
3434

3535
test('Assets with No integrations on pubspec.yaml', () async {
3636
const pubspec = 'test_resources/pubspec_assets_no_integrations.yaml';
37-
const fact = 'test_resources/actual_data/assets_no_integrations.gen.dart';
38-
const generated =
39-
'test_resources/lib/gen/assets_no_integrations.gen.dart';
40-
41-
await expectedAssetsGen(pubspec, generated, fact);
37+
await expectedAssetsGen(pubspec);
4238
});
4339

4440
test('Assets with no image integration', () async {
4541
const pubspec = 'test_resources/pubspec_assets_no_image_integration.yaml';
46-
const fact =
47-
'test_resources/actual_data/assets_no_image_integration.gen.dart';
48-
const generated =
49-
'test_resources/lib/gen/assets_no_image_integration.gen.dart';
50-
51-
await expectedAssetsGen(pubspec, generated, fact);
42+
await expectedAssetsGen(pubspec);
5243
});
5344

5445
test('Integration.classInstantiate', () {
@@ -62,12 +53,7 @@ void main() {
6253

6354
test('Assets with Svg integrations on pubspec.yaml', () async {
6455
const pubspec = 'test_resources/pubspec_assets_svg_integrations.yaml';
65-
const fact =
66-
'test_resources/actual_data/assets_svg_integrations.gen.dart';
67-
const generated =
68-
'test_resources/lib/gen/assets_svg_integrations.gen.dart';
69-
70-
await expectedAssetsGen(pubspec, generated, fact);
56+
await expectedAssetsGen(pubspec);
7157

7258
final integration = SvgIntegration('');
7359
expect(integration.className, 'SvgGenImage');
@@ -151,12 +137,7 @@ void main() {
151137

152138
test('Assets with Rive integrations on pubspec.yaml', () async {
153139
const pubspec = 'test_resources/pubspec_assets_rive_integrations.yaml';
154-
const fact =
155-
'test_resources/actual_data/assets_rive_integrations.gen.dart';
156-
const generated =
157-
'test_resources/lib/gen/assets_rive_integrations.gen.dart';
158-
159-
await expectedAssetsGen(pubspec, generated, fact);
140+
await expectedAssetsGen(pubspec);
160141

161142
final integration = RiveIntegration('');
162143
expect(integration.className, 'RiveGenImage');
@@ -203,12 +184,7 @@ void main() {
203184

204185
test('Assets with Lottie integrations on pubspec.yaml', () async {
205186
const pubspec = 'test_resources/pubspec_assets_lottie_integrations.yaml';
206-
const fact =
207-
'test_resources/actual_data/assets_lottie_integrations.gen.dart';
208-
const generated =
209-
'test_resources/lib/gen/assets_lottie_integrations.gen.dart';
210-
211-
await expectedAssetsGen(pubspec, generated, fact);
187+
await expectedAssetsGen(pubspec);
212188

213189
final integration = LottieIntegration('');
214190
expect(integration.className, 'LottieGenImage');

packages/core/test/assets_gen_test.dart

Lines changed: 17 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,27 @@ void main() {
1616
group('Test Assets generator', () {
1717
test('Assets on pubspec.yaml', () async {
1818
const pubspec = 'test_resources/pubspec_assets.yaml';
19-
const fact = 'test_resources/actual_data/assets.gen.dart';
20-
const generated = 'test_resources/lib/gen/assets.gen.dart';
21-
22-
await expectedAssetsGen(pubspec, generated, fact);
19+
await expectedAssetsGen(pubspec);
2320
});
2421

2522
test('Assets snake-case style on pubspec.yaml', () async {
2623
const pubspec = 'test_resources/pubspec_assets_snake_case.yaml';
27-
const fact = 'test_resources/actual_data/assets_snake_case.gen.dart';
28-
const generated = 'test_resources/lib/gen/assets_snake_case.gen.dart';
29-
30-
await expectedAssetsGen(pubspec, generated, fact);
24+
await expectedAssetsGen(pubspec);
3125
});
3226

3327
test('Assets camel-case style on pubspec.yaml', () async {
3428
const pubspec = 'test_resources/pubspec_assets_camel_case.yaml';
35-
const fact = 'test_resources/actual_data/assets_camel_case.gen.dart';
36-
const generated = 'test_resources/lib/gen/assets_camel_case.gen.dart';
37-
38-
await expectedAssetsGen(pubspec, generated, fact);
29+
await expectedAssetsGen(pubspec);
3930
});
4031

4132
test('Assets with Unknown mime type on pubspec.yaml', () async {
4233
const pubspec = 'test_resources/pubspec_unknown_mime_type.yaml';
43-
const fact =
44-
'test_resources/actual_data/assets_unknown_mime_type.gen.dart';
45-
const generated =
46-
'test_resources/lib/gen/assets_unknown_mime_type.gen.dart';
47-
48-
await expectedAssetsGen(pubspec, generated, fact);
34+
await expectedAssetsGen(pubspec);
4935
});
5036

5137
test('Assets with ignore files on pubspec.yaml', () async {
5238
const pubspec = 'test_resources/pubspec_ignore_files.yaml';
53-
const fact = 'test_resources/actual_data/assets_ignore_files.gen.dart';
54-
const generated = 'test_resources/lib/gen/assets_ignore_files.gen.dart';
55-
56-
await expectedAssetsGen(pubspec, generated, fact);
39+
await expectedAssetsGen(pubspec);
5740
});
5841

5942
test('Assets with No lists on pubspec.yaml', () async {
@@ -72,15 +55,9 @@ void main() {
7255

7356
test('Assets with package parameter enabled', () async {
7457
const pubspec = 'test_resources/pubspec_assets_package_parameter.yaml';
75-
const fact =
76-
'test_resources/actual_data/assets_package_parameter.gen.dart';
77-
const generated =
78-
'test_resources/lib/gen/assets_package_parameter.gen.dart';
79-
80-
await expectedAssetsGen(pubspec, generated, fact);
58+
final (content, _) = await expectedAssetsGen(pubspec);
8159

8260
// The generated classes have `package` fields.
83-
final content = await File(generated).readAsString();
8461
expect(content, contains("static const String package = 'test';"));
8562
expect(
8663
content,
@@ -96,67 +73,40 @@ void main() {
9673

9774
test('Assets with directory path enabled', () async {
9875
const pubspec = 'test_resources/pubspec_assets_directory_path.yaml';
99-
const fact = 'test_resources/actual_data/assets_directory_path.gen.dart';
100-
const generated = 'test_resources/lib/gen/assets_directory_path.gen.dart';
101-
await expectedAssetsGen(pubspec, generated, fact);
76+
await expectedAssetsGen(pubspec);
10277
});
10378

10479
test('Assets with directory path and package parameter enabled', () async {
10580
const pubspec =
10681
'test_resources/pubspec_assets_directory_path_with_package_parameter.yaml';
107-
const fact =
108-
'test_resources/actual_data/assets_directory_path_with_package_parameter.gen.dart';
109-
const generated =
110-
'test_resources/lib/gen/assets_directory_path_with_package_parameter.gen.dart';
111-
await expectedAssetsGen(pubspec, generated, fact);
82+
await expectedAssetsGen(pubspec);
11283
});
11384

11485
test('Assets with excluded files and directories', () async {
11586
const pubspec = 'test_resources/pubspec_assets_exclude_files.yaml';
116-
const fact =
117-
'test_resources/actual_data/assets_package_exclude_files.gen.dart';
118-
const generated =
119-
'test_resources/lib/gen/assets_package_exclude_files.gen.dart';
120-
121-
await expectedAssetsGen(pubspec, generated, fact);
87+
await expectedAssetsGen(pubspec);
12288
});
12389

12490
test('Assets with change the class name', () async {
12591
const pubspec = 'test_resources/pubspec_assets_change_class_name.yaml';
126-
const fact =
127-
'test_resources/actual_data/assets_change_class_name.gen.dart';
128-
const generated =
129-
'test_resources/lib/gen/assets_change_class_name.gen.dart';
130-
131-
await expectedAssetsGen(pubspec, generated, fact);
92+
await expectedAssetsGen(pubspec);
13293
});
13394

13495
test('Assets with parse metadata enabled', () async {
13596
const pubspec = 'test_resources/pubspec_assets_parse_metadata.yaml';
136-
const fact = 'test_resources/actual_data/assets_parse_metadata.gen.dart';
137-
const generated = 'test_resources/lib/gen/assets_parse_metadata.gen.dart';
138-
139-
await expectedAssetsGen(pubspec, generated, fact);
97+
await expectedAssetsGen(pubspec);
14098
});
14199

142100
test('Assets with flavored assets', () async {
143101
const pubspec = 'test_resources/pubspec_assets_flavored.yaml';
144-
const fact = 'test_resources/actual_data/assets_flavored.gen.dart';
145-
const generated = 'test_resources/lib/gen/assets_flavored.gen.dart';
146-
147-
await expectedAssetsGen(pubspec, generated, fact);
102+
await expectedAssetsGen(pubspec);
148103
});
149104

150105
test('Assets with duplicate flavoring entries', () async {
151106
const pubspec =
152107
'test_resources/pubspec_assets_flavored_duplicate_entry.yaml';
153-
const fact =
154-
'test_resources/actual_data/assets_flavored_duplicate_entry.gen.dart';
155-
const generated =
156-
'test_resources/lib/gen/assets_flavored_duplicate_entry.gen.dart';
157-
158108
await expectLater(
159-
() => runAssetsGen(pubspec, generated, fact),
109+
() => expectedAssetsGen(pubspec),
160110
throwsA(isA<StateError>()),
161111
);
162112
});
@@ -232,10 +182,7 @@ void main() {
232182
() async {
233183
const pubspec = 'test_resources/pubspec_assets.yaml';
234184
const build = 'test_resources/build_assets.yaml';
235-
const fact = 'test_resources/actual_data/build_assets.gen.dart';
236-
const generated = 'test_resources/lib/build_gen/assets.gen.dart';
237-
238-
await expectedAssetsGen(pubspec, generated, fact, build: build);
185+
await expectedAssetsGen(pubspec, build: build);
239186
},
240187
);
241188

@@ -244,10 +191,7 @@ void main() {
244191
() async {
245192
const pubspec = 'test_resources/pubspec_assets.yaml';
246193
const build = 'test_resources/build_runner_assets.yaml';
247-
const fact = 'test_resources/actual_data/build_runner_assets.gen.dart';
248-
const generated = 'test_resources/lib/build_gen/assets.gen.dart';
249-
250-
await expectedAssetsGen(pubspec, generated, fact, build: build);
194+
await expectedAssetsGen(pubspec, build: build);
251195
},
252196
);
253197

@@ -256,24 +200,18 @@ void main() {
256200
() async {
257201
const pubspec = 'test_resources/pubspec_assets.yaml';
258202
const build = 'test_resources/build_empty.yaml';
259-
const fact = 'test_resources/actual_data/build_empty.gen.dart';
260-
const generated = 'test_resources/lib/build_gen/assets.gen.dart';
261-
262-
await expectedAssetsGen(pubspec, generated, fact, build: build);
203+
await expectedAssetsGen(pubspec, build: build);
263204
},
264205
);
265206

266207
test('fallback to build.yaml if valid', () async {
267208
const pubspec = 'test_resources/pubspec_assets.yaml';
268-
const fact = 'test_resources/actual_data/build_assets.gen.dart';
269-
const generated = 'test_resources/lib/build_gen/assets.gen.dart';
270-
271209
final buildFile = File('build.yaml');
272210
final originalBuildContent = buildFile.readAsStringSync();
273211
buildFile.writeAsStringSync(
274212
File('test_resources/build_assets.yaml').readAsStringSync(),
275213
);
276-
await expectedAssetsGen(pubspec, generated, fact).whenComplete(() {
214+
await expectedAssetsGen(pubspec).whenComplete(() {
277215
buildFile.writeAsStringSync(originalBuildContent);
278216
});
279217
});

packages/core/test/colors_gen_test.dart

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ void main() {
1313
group('Test Color generator', () {
1414
test('Colors on pubspec.yaml', () async {
1515
const pubspec = 'test_resources/pubspec_colors.yaml';
16-
const fact = 'test_resources/actual_data/colors.gen.dart';
17-
const generated = 'test_resources/lib/gen/colors.gen.dart';
18-
19-
await expectedColorsGen(pubspec, generated, fact);
16+
await expectedColorsGen(pubspec);
2017
});
2118

2219
test('Wrong colors settings on pubspec.yaml', () async {
@@ -62,12 +59,7 @@ void main() {
6259

6360
test('Change the class name', () async {
6461
const pubspec = 'test_resources/pubspec_colors_change_class_name.yaml';
65-
const fact =
66-
'test_resources/actual_data/colors_change_class_name.gen.dart';
67-
const generated =
68-
'test_resources/lib/gen/colors_change_class_name.gen.dart';
69-
70-
await expectedColorsGen(pubspec, generated, fact);
62+
await expectedColorsGen(pubspec);
7163
});
7264
});
7365
}

packages/core/test/fonts_gen_test.dart

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ void main() {
1212
group('Test Fonts generator', () {
1313
test('Fonts on pubspec.yaml', () async {
1414
const pubspec = 'test_resources/pubspec_fonts.yaml';
15-
const fact = 'test_resources/actual_data/fonts.gen.dart';
16-
const generated = 'test_resources/lib/gen/fonts.gen.dart';
17-
18-
await expectedFontsGen(pubspec, generated, fact);
15+
await expectedFontsGen(pubspec);
1916
});
2017

2118
test('Wrong fonts settings on pubspec.yaml', () async {
@@ -32,22 +29,12 @@ void main() {
3229

3330
test('Change the class name', () async {
3431
const pubspec = 'test_resources/pubspec_fonts_change_class_name.yaml';
35-
const fact =
36-
'test_resources/actual_data/fonts_change_class_name.gen.dart';
37-
const generated =
38-
'test_resources/lib/gen/fonts_change_class_name.gen.dart';
39-
40-
await expectedFontsGen(pubspec, generated, fact);
32+
await expectedFontsGen(pubspec);
4133
});
4234

4335
test('Package parameter enabled', () async {
4436
const pubspec = 'test_resources/pubspec_fonts_package_parameter.yaml';
45-
const fact =
46-
'test_resources/actual_data/fonts_package_parameter.gen.dart';
47-
const generated =
48-
'test_resources/lib/gen/fonts_package_parameter.gen.dart';
49-
50-
await expectedFontsGen(pubspec, generated, fact);
37+
await expectedFontsGen(pubspec);
5138
});
5239
});
5340
}

0 commit comments

Comments
 (0)