@@ -94,7 +94,8 @@ TestModel:
94
94
expect (error, isNotNull);
95
95
expect (error, isArgumentError);
96
96
if (error is ArgumentError ) {
97
- expect (error.message, 'required is removed, follow the migration to version 7.0.0' );
97
+ expect (error.message,
98
+ 'required is removed, follow the migration to version 7.0.0' );
98
99
}
99
100
});
100
101
@@ -120,7 +121,8 @@ TestModel:
120
121
expect (error, isNotNull);
121
122
expect (error, isException);
122
123
if (error is Exception ) {
123
- expect (error.toString (), 'Exception: Could not generate all models. `array` is not added to the config file' );
124
+ expect (error.toString (),
125
+ 'Exception: Could not generate all models. `array` is not added to the config file' );
124
126
}
125
127
});
126
128
@@ -147,27 +149,34 @@ TestModel:
147
149
expect (error, isNotNull);
148
150
expect (error, isException);
149
151
if (error is Exception ) {
150
- expect (error.toString (), 'Exception: Could not generate all models. `map` is not added to the config file' );
152
+ expect (error.toString (),
153
+ 'Exception: Could not generate all models. `map` is not added to the config file' );
151
154
}
152
155
});
153
156
154
157
test ('Test simple generic fields' , () {
155
- final models = YmlGeneratorConfig (
156
- PubspecConfig ("name: test" ),
157
- """
158
+ dynamic error;
159
+ final config = YmlGeneratorConfig (
160
+ PubspecConfig ("name: test" ),
161
+ """
158
162
TestModel:
159
163
properties:
160
164
simpleStringList: List<string>
161
165
nullableStringList: List<string>?
162
166
simpleMap: Map<String, int>
163
167
""" ,
164
- '' )
165
- .models;
168
+ '' );
169
+ final models = config .models;
166
170
167
171
expect (models.length, 1 );
168
172
final model = models.first;
169
173
expect (model is ObjectModel , true );
170
174
model as ObjectModel ;
175
+ try {
176
+ config.checkIfTypesAvailable ();
177
+ } catch (e) {
178
+ error = e;
179
+ }
171
180
172
181
final simpleStringList = model.fields.getByName ("simpleStringList" );
173
182
final nullableStringList = model.fields.getByName ("nullableStringList" );
@@ -181,6 +190,8 @@ TestModel:
181
190
182
191
expect (simpleMap.type, isA <MapType >());
183
192
expect (simpleMap.isRequired, true );
193
+
194
+ expect (error, isNull);
184
195
});
185
196
test ('Test simple object reference fields' , () {
186
197
final models = YmlGeneratorConfig (
@@ -240,8 +251,9 @@ Gender:
240
251
}
241
252
expect (error, isNotNull);
242
253
expect (error, isException);
243
- if (error is Exception ){
244
- expect (error.toString (), 'Exception: item_type should be a string or integer. model: Gender' );
254
+ if (error is Exception ) {
255
+ expect (error.toString (),
256
+ 'Exception: item_type should be a string or integer. model: Gender' );
245
257
}
246
258
});
247
259
});
0 commit comments