Skip to content

Commit 8bc2651

Browse files
committed
fix tests
1 parent 8fa5c00 commit 8bc2651

File tree

3 files changed

+67
-15
lines changed

3 files changed

+67
-15
lines changed

lib/src/flutter_generator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class FlutterGenerator {
1919
final config = Config(pubspecFile);
2020
try {
2121
await config.load();
22-
} on FormatException catch (e) {
22+
} on InvalidSettingsException catch (e) {
2323
stderr.writeln(e.message);
2424
return;
2525
} on FileSystemException catch (e) {

test/assets_gen_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void main() {
6565
expect(actual, expected);
6666
});
6767

68-
test('Assets with No inegrations on pubspec.yaml', () async {
68+
test('Assets with No integrations on pubspec.yaml', () async {
6969
await FlutterGenerator(
7070
File('test_resources/pubspec_assets_no_integrations.yaml'))
7171
.build();

test/flutter_gen_test.dart

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import 'dart:io';
33

44
import 'package:flutter_gen/src/flutter_generator.dart';
5-
import 'package:flutter_gen/src/settings/config.dart';
6-
import 'package:flutter_gen/src/utils/error.dart';
75
import 'package:test/test.dart';
86

97
void main() {
@@ -16,23 +14,53 @@ void main() {
1614
});
1715
group('Test FlutterGenerator Exceptions', () {
1816
test('Not founded pubspec.yaml', () async {
19-
expect(() async {
20-
return await Config(File('test_resources/pubspec_not_founded.yaml'))
21-
.load();
22-
}, throwsA(isA<FileSystemException>()));
17+
await FlutterGenerator(File('test_resources/pubspec_not_founded.yaml'))
18+
.build();
19+
expect(
20+
File('test_resources/lib/gen/assets.gen.dart').existsSync(),
21+
isFalse,
22+
);
23+
expect(
24+
File('test_resources/lib/gen/fonts.gen.dart').existsSync(),
25+
isFalse,
26+
);
27+
expect(
28+
File('test_resources/lib/gen/colors.gen.dart').existsSync(),
29+
isFalse,
30+
);
2331
});
2432

2533
test('Empty pubspec.yaml', () async {
26-
expect(() async {
27-
return await Config(File('test_resources/pubspec_empty.yaml')).load();
28-
}, throwsA(isA<InvalidSettingsException>()));
34+
await FlutterGenerator(File('test_resources/pubspec_empty.yaml')).build();
35+
expect(
36+
File('test_resources/lib/gen/assets.gen.dart').existsSync(),
37+
isFalse,
38+
);
39+
expect(
40+
File('test_resources/lib/gen/fonts.gen.dart').existsSync(),
41+
isFalse,
42+
);
43+
expect(
44+
File('test_resources/lib/gen/colors.gen.dart').existsSync(),
45+
isFalse,
46+
);
2947
});
3048

3149
test('No settings pubspec.yaml', () async {
32-
expect(() async {
33-
return await Config(File('test_resources/pubspec_no_settings.yaml'))
34-
.load();
35-
}, throwsA(isA<InvalidSettingsException>()));
50+
await FlutterGenerator(File('test_resources/pubspec_no_settings.yaml'))
51+
.build();
52+
expect(
53+
File('test_resources/lib/gen/assets.gen.dart').existsSync(),
54+
isFalse,
55+
);
56+
expect(
57+
File('test_resources/lib/gen/fonts.gen.dart').existsSync(),
58+
isFalse,
59+
);
60+
expect(
61+
File('test_resources/lib/gen/colors.gen.dart').existsSync(),
62+
isFalse,
63+
);
3664
});
3765
});
3866

@@ -124,5 +152,29 @@ void main() {
124152
isNotEmpty,
125153
);
126154
});
155+
156+
// test('Assets with No lists on pubspec.yaml', () async {
157+
// expect(() async {
158+
// return FlutterGenerator(
159+
// File('test_resources/pubspec_assets_no_list.yaml'))
160+
// .build();
161+
// }, throwsA(isA<InvalidSettingsException>()));
162+
// });
163+
//
164+
// test('Wrong fonts settings on pubspec.yaml', () async {
165+
// expect(() async {
166+
// return FlutterGenerator(
167+
// File('test_resources/pubspec_fonts_no_family.yaml'))
168+
// .build();
169+
// }, throwsA(isA<InvalidSettingsException>()));
170+
// });
171+
//
172+
// test('Wrong colors settings on pubspec.yaml', () async {
173+
// expect(() async {
174+
// return FlutterGenerator(
175+
// File('test_resources/pubspec_colors_no_inputs.yaml'))
176+
// .build();
177+
// }, throwsA(isA<InvalidSettingsException>()));
178+
// });
127179
});
128180
}

0 commit comments

Comments
 (0)