Skip to content

Commit 4e61662

Browse files
committed
#142: added extra enum test
1 parent 14f0a32 commit 4e61662

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

test/writer/model_reader_test.dart

+31-6
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ TestModel:
9191
expect(error, isNotNull);
9292
expect(error, isArgumentError);
9393
if (error is ArgumentError) {
94-
expect(error.message,
95-
'required is removed, follow the migration to version 7.0.0');
94+
expect(error.message, 'required is removed, follow the migration to version 7.0.0');
9695
}
9796
});
9897

@@ -118,8 +117,7 @@ TestModel:
118117
expect(error, isNotNull);
119118
expect(error, isException);
120119
if (error is Exception) {
121-
expect(error.toString(),
122-
'Exception: Could not generate all models. `array` is not added to the config file');
120+
expect(error.toString(), 'Exception: Could not generate all models. `array` is not added to the config file');
123121
}
124122
});
125123

@@ -146,8 +144,7 @@ TestModel:
146144
expect(error, isNotNull);
147145
expect(error, isException);
148146
if (error is Exception) {
149-
expect(error.toString(),
150-
'Exception: Could not generate all models. `map` is not added to the config file');
147+
expect(error.toString(), 'Exception: Could not generate all models. `map` is not added to the config file');
151148
}
152149
});
153150

@@ -216,6 +213,34 @@ TestModel2:
216213
expect(nullableRef.type, isA<ObjectType>());
217214
expect(nullableRef.isRequired, false);
218215
});
216+
217+
test('Test enum item_type should be string or integer', () {
218+
dynamic error;
219+
try {
220+
YmlGeneratorConfig(
221+
PubspecConfig("name: test"),
222+
"""
223+
Gender:
224+
path: user/person/
225+
type: enum
226+
item_type: List
227+
properties:
228+
MALE:
229+
value: male
230+
FEMALE:
231+
value: female
232+
""",
233+
'')
234+
.models;
235+
} catch (e) {
236+
error = e;
237+
}
238+
expect(error, isNotNull);
239+
expect(error, isException);
240+
if(error is Exception){
241+
expect(error.toString(), 'Exception: item_type should be a string or integer. model: Gender');
242+
}
243+
});
219244
});
220245
}
221246

0 commit comments

Comments
 (0)