11@TestOn ('vm' )
22import 'dart:io' ;
33
4- import 'package:dart_style/dart_style.dart' ;
54import 'package:flutter_gen/src/flutter_generator.dart' ;
6- import 'package:flutter_gen/src/generators/assets_generator.dart' ;
7- import 'package:flutter_gen/src/generators/colors_generator.dart' ;
8- import 'package:flutter_gen/src/generators/fonts_generator.dart' ;
95import 'package:flutter_gen/src/settings/config.dart' ;
6+ import 'package:flutter_gen/src/utils/error.dart' ;
107import 'package:test/test.dart' ;
118
129void main () {
@@ -17,8 +14,7 @@ void main() {
1714 dir.deleteSync (recursive: true );
1815 }
1916 });
20-
21- group ('Test FlutterGenerator incorrect case' , () {
17+ group ('Test FlutterGenerator Exceptions' , () {
2218 test ('Not founded pubspec.yaml' , () async {
2319 expect (() async {
2420 return await Config (File ('test_resources/pubspec_not_founded.yaml' ))
@@ -29,18 +25,18 @@ void main() {
2925 test ('Empty pubspec.yaml' , () async {
3026 expect (() async {
3127 return await Config (File ('test_resources/pubspec_empty.yaml' )).load ();
32- }, throwsFormatException );
28+ }, throwsA ( isA < InvalidSettingsException >()) );
3329 });
3430
3531 test ('No settings pubspec.yaml' , () async {
3632 expect (() async {
3733 return await Config (File ('test_resources/pubspec_no_settings.yaml' ))
3834 .load ();
39- }, throwsFormatException );
35+ }, throwsA ( isA < InvalidSettingsException >()) );
4036 });
4137 });
4238
43- group ('Test FlutterGenerator correct case ' , () {
39+ group ('Test FlutterGenerator' , () {
4440 test ('pubspec.yaml' , () async {
4541 await FlutterGenerator (File ('test_resources/pubspec.yaml' )).build ();
4642 expect (
@@ -128,106 +124,5 @@ void main() {
128124 isNotEmpty,
129125 );
130126 });
131-
132- test ('Assets on pubspec.yaml' , () async {
133- final pubspec = File ('test_resources/pubspec_assets.yaml' );
134- final config = await Config (pubspec).load ();
135- final formatter = DartFormatter (
136- pageWidth: config.flutterGen.lineLength, lineEnding: '\n ' );
137-
138- final actual = generateAssets (
139- pubspec, formatter, config.flutterGen, config.flutter.assets);
140- final expected = File ('test_resources/actual_data/assets.gen.dart' )
141- .readAsStringSync ()
142- .replaceAll ('\r\n ' , '\n ' );
143-
144- expect (actual, expected);
145- });
146-
147- test ('Assets snake-case style on pubspec.yaml' , () async {
148- final pubspec = File ('test_resources/pubspec_assets_snake_case.yaml' );
149- final config = await Config (pubspec).load ();
150- final formatter = DartFormatter (
151- pageWidth: config.flutterGen.lineLength, lineEnding: '\n ' );
152-
153- final actual = generateAssets (
154- pubspec, formatter, config.flutterGen, config.flutter.assets);
155- final expected =
156- File ('test_resources/actual_data/assets_snake_case.gen.dart' )
157- .readAsStringSync ()
158- .replaceAll ('\r\n ' , '\n ' );
159-
160- expect (actual, expected);
161- });
162-
163- test ('Assets camel-case style on pubspec.yaml' , () async {
164- final pubspec = File ('test_resources/pubspec_assets_camel_case.yaml' );
165- final config = await Config (pubspec).load ();
166- final formatter = DartFormatter (
167- pageWidth: config.flutterGen.lineLength, lineEnding: '\n ' );
168-
169- final actual = generateAssets (
170- pubspec, formatter, config.flutterGen, config.flutter.assets);
171- final expected =
172- File ('test_resources/actual_data/assets_camel_case.gen.dart' )
173- .readAsStringSync ()
174- .replaceAll ('\r\n ' , '\n ' );
175-
176- expect (actual, expected);
177- });
178-
179- test ('Assets with No inegrations on pubspec.yaml' , () async {
180- await FlutterGenerator (
181- File ('test_resources/pubspec_assets_no_integrations.yaml' ))
182- .build ();
183- expect (
184- File ('test_resources/lib/gen/assets.gen.dart' ).readAsStringSync (),
185- isNotEmpty,
186- );
187-
188- final pubspec =
189- File ('test_resources/pubspec_assets_no_integrations.yaml' );
190- final config = await Config (pubspec).load ();
191- final formatter = DartFormatter (
192- pageWidth: config.flutterGen.lineLength, lineEnding: '\n ' );
193-
194- final actual = generateAssets (
195- pubspec, formatter, config.flutterGen, config.flutter.assets);
196- final expected =
197- File ('test_resources/actual_data/assets_no_integrations.gen.dart' )
198- .readAsStringSync ()
199- .replaceAll ('\r\n ' , '\n ' );
200-
201- expect (actual, expected);
202- });
203-
204- test ('Fonts on pubspec.yaml' , () async {
205- final config =
206- await Config (File ('test_resources/pubspec_fonts.yaml' )).load ();
207- final formatter = DartFormatter (
208- pageWidth: config.flutterGen.lineLength, lineEnding: '\n ' );
209-
210- final actual = generateFonts (formatter, config.flutter.fonts);
211- final expected = File ('test_resources/actual_data/fonts.gen.dart' )
212- .readAsStringSync ()
213- .replaceAll ('\r\n ' , '\n ' );
214-
215- expect (actual, expected);
216- });
217-
218- test ('Colors on pubspec.yaml' , () async {
219- final pubspec = File ('test_resources/pubspec_colors.yaml' );
220- final config = await Config (pubspec).load ();
221- final formatter = DartFormatter (
222- pageWidth: config.flutterGen.lineLength, lineEnding: '\n ' );
223-
224- final actual =
225- generateColors (pubspec, formatter, config.flutterGen.colors);
226- final expected = File ('test_resources/actual_data/colors.gen.dart' )
227- .readAsStringSync ()
228- .replaceAll ('\r\n ' , '\n ' );
229-
230- expect (actual, expected);
231- });
232127 });
233128}
0 commit comments